当前位置: 首页 > news >正文

长沙做网站咨询公司学校校园网站使用

长沙做网站咨询公司,学校校园网站使用,鹤壁网站建设鹤壁,网站设计报价单模板开发完接口#xff0c;接下来我们需要对我们开发的接口进行测试。接口测试的方法比较多#xff0c;使用接口工具或者Python来测试都可以#xff0c;工具方面比如之前我们学习过的Postman或者Jmeter #xff0c;Python脚本测试可以使用Requests unittest来测试。 测试思路…开发完接口接下来我们需要对我们开发的接口进行测试。接口测试的方法比较多使用接口工具或者Python来测试都可以工具方面比如之前我们学习过的Postman或者Jmeter Python脚本测试可以使用Requests unittest来测试。 测试思路 功能测试数据的增删改查 异常测试未授权参数异常等 Postman测试 使用测试工具Postman测试结果如下所示 user接口测试 查询所有用户 创建用户 修改用户 删除用户 未授权测试 groups接口测试 查询所有groups数据 修改group数据 删除groups RequestsUnittest 在api目录下面新建一个test_unittest.py代码实现如下: tests_unittest.py import requests import unittestclass UserTest(unittest.TestCase):def setUp(self):self.base_urlhttp://127.0.0.1:8000/usersself.auth(51zxw,zxw20182018)def test_get_user(self):rrequests.get(self.base_url/1/,authself.auth)resultr.json()self.assertEqual(result[username],51zxw)self.assertEqual(result[email],51zxw163.com)def test_add_user(self):form_data{username:zxw222,email:zxw668qq.com,groups:http://127.0.0.1:8000/groups/2/}rrequests.post(self.base_url/,dataform_data,authself.auth)resultr.json()self.assertEqual(result[username],zxw222)def test_delete_user(self):rrequests.delete(self.base_url/11/,authself.auth)self.assertEqual(r.status_code,204)def test_update_user(self):form_data{email:2222163.com}rrequests.patch(self.base_url/2/,authself.auth,dataform_data)resultr.json()self.assertEqual(result[email],2222163.com)def test_no_auth(self):rrequests.get(self.base_url)resultr.json()self.assertEqual(result[detail],Authentication credentials were not provided.)class GroupTest(unittest.TestCase):def setUp(self):self.base_urlhttp://127.0.0.1:8000/groupsself.auth(51zxw,zxw20182018)def test_group_developer(self):rrequests.get(self.base_url/7/,authself.auth)resultr.json()self.assertEqual(result[name],Developer)def test_add_group(self):form_data{name:Pm}rrequests.post(self.base_url/,authself.auth,dataform_data)resultr.json()self.assertEqual(result[name],Pm)def test_update_group(self):form_data{name:Boss}rrequests.patch(self.base_url/6/,authself.auth,dataform_data)resultr.json()self.assertEqual(result[name],Boss)def test_detele_group(self):rrequests.delete(self.base_url/6/,authself.auth)self.assertEqual(r.status_code,204)if __name__ __main__:unittest.main() Django自带测试模块 打开api目录下面的tests文件编写如下测试代码 tests.py from django.test import TestCase import requests# Create your tests here. class UserTest(TestCase):def setUp(self):self.base_urlhttp://127.0.0.1:8000/usersself.auth(51zxw,xxxxx)def test_get_user(self):rrequests.get(self.base_url/1/,authself.auth)resultr.json()self.assertEqual(result[username],51zxw)self.assertEqual(result[email],zxw886qq.com)# unittest.skip(skip add user)def test_add_user(self):form_data{username:zxw222,email:zxw668qq.com,groups:http://127.0.0.1:8000/groups/2/}rrequests.post(self.base_url/,dataform_data,authself.auth)resultr.json()self.assertEqual(result[username],zxw222)# unittest.skip(skip test_delete_user)def test_delete_user(self):rrequests.delete(self.base_url/11/,authself.auth)self.assertEqual(r.status_code,204)def test_update_user(self):form_data{email:2222163.com}rrequests.patch(self.base_url/2/,authself.auth,dataform_data)resultr.json()self.assertEqual(result[email],2222163.com)def test_user_already_exists(self):form_data {username: zxw222, email: zxw668qq.com, groups: http://127.0.0.1:8000/groups/2/}r requests.post(self.base_url /, dataform_data, authself.auth)result r.json()#预期返回值{username:[A user with that username already exists.]}self.assertEqual(result[username][0], A user with that username already exists.)def test_no_auth(self):rrequests.get(self.base_url)resultr.json()self.assertEqual(result[detail],Authentication credentials were not provided.)class GroupTest(TestCase):def setUp(self):self.base_urlhttp://127.0.0.1:8000/groupsself.auth(51zxw,xxxxxx)def test_group_developer(self):rrequests.get(self.base_url/3/,authself.auth)resultr.json()self.assertEqual(result[name],Pm)# unittest.skip(skip test_add_group)def test_add_group(self):form_data{name:Leader}rrequests.post(self.base_url/,authself.auth,dataform_data)resultr.json()self.assertEqual(result[name],Leader)def test_update_group(self):form_data{name:Boss}rrequests.patch(self.base_url/6/,authself.auth,dataform_data)resultr.json()self.assertEqual(result[name],Boss)def test_detele_group(self):rrequests.delete(self.base_url/6/,authself.auth)self.assertEqual(r.status_code,204) 运行方式打开cmd使用如下命令来运行即可 D:\django_restfulpython manage.py test 上面命令是默认测试全部的用例如果想测试部分用例则可以使用如下命令 测试指定的测试类 D:\django_restfulpython manage.py test api.tests.UserTest 测试具体的某一条具体用例 D:\django_restfulpython manage.py test api.tests.UserTest.test_get_user 报错相关 1.迁移数据库时没有权限写入 File C:\Users\jli75\AppData\Local\Programs\Python\Python37\lib\site-packages\MySQLdb\connections.py, line 280, in query_mysql.connection.query(self, query) django.db.utils.InternalError: (7, Error on rename of .\\httprunnermanager\\#sql-1178_7.frm to .\\httprunnermanager\\djcelery_taskstate.frm (Errcode: 13 - Permission denied)) 原因可能是杀毒软件通过阻止修改frm文件来解决此问题。通过在杀毒软件威胁防护高级选项中禁用按访问扫描并杀毒软件设置为忽略这些扩展名来解决此问题 迁移数据库时没有清除之前的迁移文件migrations File C:\Users\jli75\AppData\Local\Programs\Python\Python37\lib\site-packages\MySQLdb\connections.py, line 280, in query_mysql.connection.query(self, query) _mysql_exceptions.OperationalError: (1050, Table djcelery_crontabschedule already exists) 解决方案删除migrations文件夹即可。 setting配置错误 raise MigrationSchemaMissing(Unable to create the django_migrations table (%s) % exc) django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near (6) NOT NULL) at line 1)) 解决方案Django2.1不再支持MySQL5.5必须5.6版本以上 可以使用如下命令 查看当前Mysql版本 mysql -V mysql Ver 8.0.1-dmr for Win64 on x86_64 (MySQL Community Server (GPL)) 【软件测试行业现状】2023年干测试约等于49年入国军。未来已寄..测试人该何去何从【自动化测试、软件测试面试、性能测试】
http://www.w-s-a.com/news/848231/

相关文章:

  • 网站手机端做app开发商城设计方案
  • 在建设厅网站上查询注销建造师查域名是否注册
  • 企业网站推广方案策划公司网站在国外打开很慢使用cdn好还是国外租用服务器好
  • 龙华o2o网站建设百度不收录什么网站吗
  • 模板搭建网站百度信息流推广
  • 移动端网站制作模板自己做的网站点击赚钱
  • 网站站长如何赚钱wordpress抓取别人网站
  • 做网站媒体专门做产品定制的网站
  • 公司企业网站建设步骤免费asp网站模板
  • 台州企业网站搭建价格做留言的网站
  • 西安网站建设q.479185700強高端网站设计定制公司
  • 网站设计是平面设计吗音频文件放到网站空间里生成链接怎么做
  • seo是对网站进行什么优化可以在哪些网站做翻译兼职
  • 南宁seo网站推广服务网站建设客户分析
  • 网站属于什么公司甜品售卖网站网页设计
  • 如何在宝塔中安装wordpressseo1888网站建设
  • 网站系统cms湖南平台网站建设制作
  • 美团网站怎么做未备案网站加速
  • 通用cms网站wordpress可以商用
  • 阳江网络问政平台 周报济南seo公司案例
  • 重庆聚百思网站开发网络市场调研
  • seo工具共享网站敬请期待的英语
  • 最好看免费观看高清大全中国移动网络优化做什么的
  • 网站开发的步骤医院网站建设细节
  • 阿雷网站建设wordpress lucene
  • seo做多个网站建筑公司企业标语
  • 各大网站收录查询汕尾手机网站设计
  • 东莞网站平台费用58同城推广能免费做网站吗
  • 网站建设的组织机构做博客网站赚钱吗
  • 移动网站建设的前期规划内容南阳网站备案