How to use create_limit method in tempest

Best Python code snippet using tempest_python

test_create_limit.py

Source:test_create_limit.py Github

copy

Full Screen

1from dataclasses import dataclass2import pytest3from motor.motor_asyncio import AsyncIOMotorClient4from pytest import mark5from app.core.config import get6from app.core.errors import CreateQuantityLimit, PermissionDoesNotExist, ParamsError7from app.enums.common import 产品分类8from app.enums.equipment import 装备分类_39from app.models.user import User10from app.service.create_limit import 创建数量限制11pytestmark = mark.asyncio12@dataclass13class MockCollection(object):14 conn: AsyncIOMotorClient15 config: str16 async def count_documents(self, *args, **kwargs):17 from app import settings18 return settings.num_limit["VIP用户"][get(self.config)]19@dataclass20class MockLittleCollection(object):21 conn: AsyncIOMotorClient22 config: str23 async def count_documents(self, *args, **kwargs):24 from app import settings25 return settings.num_limit["VIP用户"][get(self.config)] - 126@mark.parametrize(27 "category, 装备分类, user",28 [29 (产品分类.equipment, 装备分类_3.选股, "免费用户"),30 (产品分类.robot, None, "VIP用户"),31 (产品分类.portfolio, None, "VIP用户"),32 (产品分类.equipment, 装备分类_3.选股, "VIP用户"),33 (产品分类.equipment, None, "VIP用户"),34 (产品分类.equipment, 装备分类_3.选股, "超级用户"),35 ],36)37async def test_check_create_quota_by_category(38 fixture_client, fixture_settings, fixture_db, logined_root_user, logined_free_user, logined_vip_user, category, 装备分类, user, mocker39):40 if user == "超级用户":41 response = await 创建数量限制(fixture_db, category, User(**logined_root_user["user"]), 装备分类)42 assert response is True43 elif user == "免费用户":44 with pytest.raises(PermissionDoesNotExist):45 await 创建数量限制(fixture_db, category, User(**logined_free_user["user"]), 装备分类)46 else:47 if category == 产品分类.equipment and 装备分类 is None:48 mocker.patch("app.service.create_limit.get_collection_by_config", side_effect=MockCollection)49 with pytest.raises(ParamsError):50 await 创建数量限制(fixture_db, category, User(**logined_vip_user["user"]), 装备分类)51 else:52 # wright53 mocker.patch("app.service.create_limit.get_collection_by_config", side_effect=MockLittleCollection)54 response = await 创建数量限制(fixture_db, category, User(**logined_vip_user["user"]), 装备分类)55 assert response is True56 # error57 mocker.patch("app.service.create_limit.get_collection_by_config", side_effect=MockCollection)58 with pytest.raises(CreateQuantityLimit):...

Full Screen

Full Screen

test_limit_view.py

Source:test_limit_view.py Github

copy

Full Screen

1import json2from .cli import cli3async def create_limit(cli):4 resp = await cli.post(5 '/limit',6 data=json.dumps(dict(country="RUS", currency="RUB", max_sum_per_month="1000.15"))7 )8 print(await resp.json())9 return (await resp.json())['limit_id']10async def test_limit_view_get(cli):11 resp = await cli.get('/limit')12 assert resp.status == 20013 limit_id = await create_limit(cli)14 resp = await cli.get(f'/limit/{limit_id}')15 assert resp.status == 20016 resp = await cli.get('/limit/0')17 assert resp.status == 40018async def test_limit_view_post(cli):19 resp = await cli.post(20 '/limit',21 data=json.dumps(dict(country="RUS", currency="RUB", max_sum_per_month="999999999.99"))22 )23 assert resp.status == 20024 resp = await cli.post(25 '/limit',26 data=json.dumps(dict(country="ERR", currency="ERR", max_sum_per_month="0"))27 )28 assert resp.status == 40029async def test_limit_view_put(cli):30 resp = await cli.put(31 '/limit/0',32 data=json.dumps(dict(country="RUS", currency="RUB", max_sum_per_month="999999999.99"))33 )34 assert resp.status == 40035 limit_id = await create_limit(cli)36 resp = await cli.put(37 f'/limit/{limit_id}',38 data=json.dumps(dict(country="RUS", currency="RUB", max_sum_per_month="11.111"))39 )40 assert resp.status == 20041 resp = await cli.put(42 '/limit/0',43 data=json.dumps(dict(country="ERR", currency="ERR", max_sum_per_month="0"))44 )45 assert resp.status == 40046async def test_limit_view_delete(cli):47 resp = await cli.delete('/limit/0')48 assert resp.status == 40049 print(await resp.json())50 limit_id = await create_limit(cli)51 resp = await cli.delete(f'/limit/{limit_id}')...

Full Screen

Full Screen

signals.py

Source:signals.py Github

copy

Full Screen

...3# from django.db.models.signals import post_save4# from django.dispatch import receiver5#6#7# def create_limit(sender, instance, created, **kwargs):8#9# if created:10# Limits.objects.create(owner=instance)11# print("limit created")12#13#14# post_save.connect(create_limit, sender=User)15#16#17# def update_limit(sender, instance, created, **kwargs):18#19# if created == False:20# instance.limit.save()21# print("limit updated")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful