Discussion on interface test Framework--python Series 7

Source: Internet
Author: User

Click "Blue Name" under the heading to quickly follow

Insist is to share, handling is knowledge, the diagram is everyone's progress, no fee training, no wasted blowing water, like on the attention, forwarding (free to help more partners) to exchange, want to know the knowledge please leave a message, to bring you more value, is the direction we look forward to, there is more interest in the Welcome to learn, our subscription number, Contact information is as follows:

More books, please look forward to

Background notes

Python series of courses also have a period of time, we insist, step by step, today is the last lesson to share, look at the interface test framework of the mystery, the small strange lead everyone together to complete the 7th lesson, hope to be able to read the knowledge point, hands-on practice, and then give the example code comparison, finally see the homework sentiment, If you want to learn, look down (this is the 7th lesson, the corresponding assignment is the 6th question).

1 Job Content

Topic 6:

6th Job Requirement: (Framework to complete the interface of the personal HTTP protocol, based on the 5th job)

1, including get and post requests, and take the weather forecast this interface as an example

2, the script data separation, the common method encapsulation, the result is deposited in the MySQL database, simultaneously the statistic test case success rate, the failure ratio (generates HTML format)

3, the database table itself design, field requirements and Excel consistent (name can be different)

4, Submission time: 2016-4-6 before noon

5. Reference information:

Get weather conditions by passing in CityName and CountryName

Url:http://www.webservicex.net/globalweather.asmx/getweather

Parameters: Cityname= "Beijing" and Countryname= "China"

Method: Post

Ideas:

1, on the basis of the last job, the result file is written to the MySQL database;

2, on the basis of the last job, extracting information to generate HTML report;

3, Python generated HTML can use a third-party library: PYH, you can also use the normal method, write-only.

4, Judge method: "If method = = ' Post '":, always not established, is because reading Excel is the return value of text:u ' post ', changed to testdatadict[' method '].value just fine.

5. Simple report:

reference: into QQ Group (283440449) Download

2 Colleague Job Summary

1, installation MySQLdb

1, installation error, hint: Pythonversion 2.7 required which was not found in the registry.

According to the method found on the Internet, paste a registered Python code after the run can be installed.

Post-Installation test import MYSQLDB error: Import_mysql importerror:dll load failed:%1 is not a valid WIN32 application.

2. Depending on the search problem, the reason is that 64-bit Python and 32-bit mysqldb are used.

3, re-download Mysql-python-1.2.3.win-amd64-py2.7.exe after installation can be used.

2. Take care of the database

1, self download mysql too slow, looking for a development to a (not development, test environment), is the daily use.

2. Create a library yourself, create a table

CREATE TABLE Weatherdata (ID int (4) Notnull primary key auto_increment, Description char (a) not NULL, Method char (NO) NULL, CityName char (a) not NULL, CountryName char (a) NOT NULL, Expchar (a) not NULL, Act char (+) NOT NULL, Result char ( ) not NULL, restimedouble (16,4));

3. Adding a method for writing to the MySQL table

Create a new insertmysqltable function, get the pointer, pass in the written SQL, execute, insert the data of the parameter.

4. Add a method to read the MySQL table output HTML

1. Create a new readmysqltable function, get pointers, pass in the written SQL, execute, read the contents of the table.

2. Read each row of the table and write to the HTML by style. Several small functions are also written to handle the header, footer, and so on.

5. Modify the original function

1. Add incoming methods judgment in Getrequest, split post and get processing. Handle situations where data is not available and modify other details.

2. Modify the readtable, add the Read method and pass in the dictionary.

3. Modify the edittable to modify the position selected when working with the table.

6. Places to be improved

1. The work is written in a hurry, many details are not in-depth consideration, including some fault-tolerant processing.

2. For the database structure, it is too simple to add a time field.

3. The output HTML is ugly and does not consider paging when there is too much data.

3 post-language

To this, our Python series of course sharing complete, can be carefully aftertaste, this is starting from 0, step, virtually into the interface test framework of the course, of course, to here is just a beginning, the framework needs to be the knowledge point we are basically involved, and practice, practice by individuals, the future of optimization ideas, We can continue to explore, the future use of experience needs us all to exchange and share, engaged in Python this piece, with our actions to ignite our enthusiasm, participate in the harvest is money to buy, action up, hope the next share is you, yes you!

Recommended articles

Discussion on interface test Framework--python Series 1

Discussion on interface test Framework--python series 2

Discussion on interface test Framework--python Series 3

Discussion on interface test Framework--python series 4

Discussion on interface test Framework--python Series 5

Discussion on interface test Framework--python Series 6

Python crawler--grasping fiction

Wonderful review, everywhere

JMeter Essays (20) How to write to a database synchronously when writing to a JTL file

Interface Automation Test--Basic article

Fiddler record JMeter script, dry share

JMeter interface Automation, you dare to think, I dare to play

Interface Test Combat--SOAPUI Pro5.1.2

Test the way, talk about ideas, talk about means

Warm knowledge--history list

Jenkins Series automatic Tag

↓↓↓ click on "Read the original" "See More Information"

Discussion on interface test Framework--python Series 7

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.