How to use test_get_empty method in autotest

Best Python code snippet using autotest_python

test_mercator.py

Source:test_mercator.py Github

copy

Full Screen

...78 assert IResourceSheet.providedBy(inst)79 assert verifyObject(IResourceSheet, inst)80 assert inst.meta.isheet == ITitle81 assert inst.meta.schema_class == TitleSchema82 def test_get_empty(self, meta, context):83 inst = meta.sheet_class(meta, context, None)84 wanted = {'title': ''}85 assert inst.get() == wanted86class TestUserInfoSheet:87 @fixture88 def meta(self):89 from adhocracy_mercator.sheets.mercator import userinfo_meta90 return userinfo_meta91 @fixture92 def context(self):93 from adhocracy_core.interfaces import IItem94 return testing.DummyResource(__provides__=IItem)95 def test_create_valid(self, meta, context):96 from zope.interface.verify import verifyObject97 from adhocracy_core.interfaces import IResourceSheet98 from adhocracy_mercator.sheets.mercator import IUserInfo99 from adhocracy_mercator.sheets.mercator import UserInfoSchema100 inst = meta.sheet_class(meta, context, None)101 assert IResourceSheet.providedBy(inst)102 assert verifyObject(IResourceSheet, inst)103 assert inst.meta.isheet == IUserInfo104 assert inst.meta.schema_class == UserInfoSchema105 def test_get_empty(self, meta, context):106 inst = meta.sheet_class(meta, context, None)107 wanted = {'family_name': '',108 'personal_name': '',109 'country': ''}110 assert inst.get() == wanted111class TestOrganizationInfoSheet:112 @fixture113 def meta(self):114 from adhocracy_mercator.sheets.mercator import organizationinfo_meta115 return organizationinfo_meta116 @fixture117 def context(self):118 from adhocracy_core.interfaces import IItem119 return testing.DummyResource(__provides__=IItem)120 def test_create_valid(self, meta, context):121 from zope.interface.verify import verifyObject122 from adhocracy_core.interfaces import IResourceSheet123 from adhocracy_mercator.sheets.mercator import IOrganizationInfo124 from adhocracy_mercator.sheets.mercator import OrganizationInfoSchema125 inst = meta.sheet_class(meta, context, None)126 assert IResourceSheet.providedBy(inst)127 assert verifyObject(IResourceSheet, inst)128 assert inst.meta.isheet == IOrganizationInfo129 assert inst.meta.schema_class == OrganizationInfoSchema130 def test_get_empty(self, meta, context):131 inst = meta.sheet_class(meta, context, None)132 wanted = {'country': '',133 'help_request': '',134 'name': '',135 'planned_date': None,136 'status': 'other',137 'status_other': '',138 'website': '',139 }140 assert inst.get() == wanted141class TestOrganizationInfoSchema:142 @fixture143 def inst(self):144 from adhocracy_mercator.sheets.mercator import OrganizationInfoSchema145 return OrganizationInfoSchema()146 @fixture147 def cstruct_required(self):148 return {'country': 'DE',149 'name': 'Name',150 'status': 'planned_nonprofit',151 }152 def test_deserialize_empty(self, inst):153 from colander import Invalid154 cstruct = {}155 with raises(Invalid) as error:156 inst.deserialize(cstruct)157 assert error.value.asdict() == {'status': 'Required'}158 def test_deserialize_with_required(self, inst, cstruct_required):159 wanted = cstruct_required # cstruct and appstruct are the same here160 assert inst.deserialize(cstruct_required) == wanted161 def test_deserialize_with_status_other_and_no_description(162 self, inst, cstruct_required):163 from colander import Invalid164 cstruct = cstruct_required165 cstruct['status'] = 'other'166 with raises(Invalid) as error:167 inst.deserialize(cstruct)168 assert error.value.asdict() == {'status_other':169 'Required iff status == other'}170 def test_deserialize_without_name(self, inst, cstruct_required):171 from colander import Invalid172 cstruct = cstruct_required173 cstruct['status'] = 'planned_nonprofit'174 cstruct['name'] = None175 with raises(Invalid) as error:176 inst.deserialize(cstruct)177 assert error.value.asdict() == {'name': 'Required iff status != other'}178 def test_deserialize_without_country(self, inst, cstruct_required):179 from colander import Invalid180 cstruct = cstruct_required181 cstruct['status'] = 'planned_nonprofit'182 cstruct['country'] = None183 with raises(Invalid) as error:184 inst.deserialize(cstruct)185 assert error.value.asdict() == {'country':186 'Required iff status != other'}187 def test_deserialize_with_status_and_description(self, inst,188 cstruct_required):189 cstruct = cstruct_required190 cstruct['status'] = 'other'191 cstruct['status_other'] = 'Description'192 wanted = cstruct193 assert inst.deserialize(cstruct_required) == wanted194class TestIntroductionSheet:195 @fixture196 def meta(self):197 from adhocracy_mercator.sheets.mercator import introduction_meta198 return introduction_meta199 @fixture200 def context(self):201 from adhocracy_core.interfaces import IItem202 return testing.DummyResource(__provides__=IItem)203 def test_create_valid(self, meta, context):204 from zope.interface.verify import verifyObject205 from adhocracy_core.interfaces import IResourceSheet206 from adhocracy_mercator.sheets.mercator import IIntroduction207 from adhocracy_mercator.sheets.mercator import IntroductionSchema208 inst = meta.sheet_class(meta, context, None)209 assert IResourceSheet.providedBy(inst)210 assert verifyObject(IResourceSheet, inst)211 assert inst.meta.isheet == IIntroduction212 assert inst.meta.schema_class == IntroductionSchema213 def test_get_empty(self, meta, context):214 inst = meta.sheet_class(meta, context, None)215 wanted = {'picture': None, 'teaser': ''}216 assert inst.get() == wanted217class TestDescriptionSheet:218 @fixture219 def meta(self):220 from adhocracy_mercator.sheets.mercator import description_meta221 return description_meta222 @fixture223 def context(self):224 from adhocracy_core.interfaces import IItem225 return testing.DummyResource(__provides__=IItem)226 @fixture227 def resource(self):228 from adhocracy_mercator.sheets.mercator import IDescription229 return testing.DummyResource(__provides__=IDescription)230 def test_create_valid(self, meta, context):231 from zope.interface.verify import verifyObject232 from adhocracy_core.interfaces import IResourceSheet233 from adhocracy_mercator.sheets.mercator import IDescription234 from adhocracy_mercator.sheets.mercator import DescriptionSchema235 inst = meta.sheet_class(meta, context, None)236 assert IResourceSheet.providedBy(inst)237 assert verifyObject(IResourceSheet, inst)238 assert inst.meta.isheet == IDescription239 assert inst.meta.schema_class == DescriptionSchema240 def test_get_empty(self, meta, context):241 inst = meta.sheet_class(meta, context, None)242 wanted = {'description': '',243 }244 assert inst.get() == wanted245class TestLocationSheet:246 @fixture247 def meta(self):248 from adhocracy_mercator.sheets.mercator import location_meta249 return location_meta250 @fixture251 def context(self):252 from adhocracy_core.interfaces import IItem253 return testing.DummyResource(__provides__=IItem)254 @fixture255 def resource(self):256 from adhocracy_mercator.sheets.mercator import ILocation257 return testing.DummyResource(__provides__=ILocation)258 def test_create_valid(self, meta, context):259 from zope.interface.verify import verifyObject260 from adhocracy_core.interfaces import IResourceSheet261 from adhocracy_mercator.sheets.mercator import ILocation262 from adhocracy_mercator.sheets.mercator import LocationSchema263 inst = meta.sheet_class(meta, context, None)264 assert IResourceSheet.providedBy(inst)265 assert verifyObject(IResourceSheet, inst)266 assert inst.meta.isheet == ILocation267 assert inst.meta.schema_class == LocationSchema268 def test_get_empty(self, meta, context):269 inst = meta.sheet_class(meta, context, None)270 wanted = {'location_is_specific': False,271 'location_specific_1': '',272 'location_specific_2': '',273 'location_specific_3': '',274 'location_is_linked_to_ruhr': False,275 'location_is_online': False,276 }277 assert inst.get() == wanted278class TestOutcomeSheet:279 @fixture280 def meta(self):281 from adhocracy_mercator.sheets.mercator import outcome_meta282 return outcome_meta283 @fixture284 def context(self):285 from adhocracy_core.interfaces import IItem286 return testing.DummyResource(__provides__=IItem)287 def test_create_valid(self, meta, context):288 from zope.interface.verify import verifyObject289 from adhocracy_core.interfaces import IResourceSheet290 from adhocracy_mercator.sheets.mercator import IOutcome291 from adhocracy_mercator.sheets.mercator import OutcomeSchema292 inst = meta.sheet_class(meta, context, None)293 assert IResourceSheet.providedBy(inst)294 assert verifyObject(IResourceSheet, inst)295 assert inst.meta.isheet == IOutcome296 assert inst.meta.schema_class == OutcomeSchema297 def test_get_empty(self, meta, context):298 inst = meta.sheet_class(meta, context, None)299 wanted = {'outcome': ''}300 assert inst.get() == wanted301class TestFinanceSheet:302 @fixture303 def meta(self):304 from adhocracy_mercator.sheets.mercator import finance_meta305 return finance_meta306 @fixture307 def context(self):308 from adhocracy_core.interfaces import IItem309 return testing.DummyResource(__provides__=IItem)310 def test_create_valid(self, meta, context):311 from zope.interface.verify import verifyObject312 from adhocracy_core.interfaces import IResourceSheet313 from adhocracy_mercator.sheets.mercator import IFinance314 from adhocracy_mercator.sheets.mercator import FinanceSchema315 inst = meta.sheet_class(meta, context, None)316 assert IResourceSheet.providedBy(inst)317 assert verifyObject(IResourceSheet, inst)318 assert inst.meta.isheet == IFinance319 assert inst.meta.schema_class == FinanceSchema320 def test_get_empty(self, meta, context):321 from decimal import Decimal322 inst = meta.sheet_class(meta, context, None)323 wanted = {'budget': Decimal(0),324 'granted': False,325 'other_sources': '',326 'requested_funding': Decimal(0)}327 assert inst.get() == wanted328class TestFinanceSchema:329 @fixture330 def inst(self):331 from adhocracy_mercator.sheets.mercator import FinanceSchema332 return FinanceSchema()333 @fixture334 def cstruct_required(self):335 return {'requested_funding': '500',336 'budget': '100.00',337 }338 def test_deserialize_empty(self, inst):339 cstruct = {}340 with raises(colander.Invalid) as error:341 inst.deserialize(cstruct)342 assert error.value.asdict() == {'requested_funding': 'Required',343 'budget': 'Required'}344 def test_deserialize_with_required(self, inst, cstruct_required):345 from decimal import Decimal346 wanted = {'requested_funding': Decimal(500),347 'budget': Decimal(100),348 'granted': False,349 }350 assert inst.deserialize(cstruct_required) == wanted351 def test_deserialize_requested_funding_field_lt_0(352 self, inst, cstruct_required):353 cstruct_required['requested_funding'] = '-1'354 with raises(colander.Invalid):355 inst.deserialize(cstruct_required)356 def test_deserialize_requested_funding_field_gte_0(357 self, inst, cstruct_required):358 from decimal import Decimal359 cstruct_required['requested_funding'] = '0.00'360 result = inst.deserialize(cstruct_required)361 assert result['requested_funding'] == Decimal(0)362 def test_deserialize_requested_funding_field_gt_50000(363 self, inst, cstruct_required):364 cstruct_required['requested_funding'] = '500000.01'365 with raises(colander.Invalid):366 inst.deserialize(cstruct_required)367class TestExperienceSheet:368 @fixture369 def meta(self):370 from adhocracy_mercator.sheets.mercator import experience_meta371 return experience_meta372 @fixture373 def context(self):374 from adhocracy_core.interfaces import IItem375 return testing.DummyResource(__provides__=IItem)376 def test_create_valid(self, meta, context):377 from zope.interface.verify import verifyObject378 from adhocracy_core.interfaces import IResourceSheet379 from adhocracy_mercator.sheets.mercator import IExperience380 from adhocracy_mercator.sheets.mercator import ExperienceSchema381 inst = meta.sheet_class(meta, context, None)382 assert IResourceSheet.providedBy(inst)383 assert verifyObject(IResourceSheet, inst)384 assert inst.meta.isheet == IExperience385 assert inst.meta.schema_class == ExperienceSchema386 def test_get_empty(self, meta, context):387 inst = meta.sheet_class(meta, context, None)388 wanted = {'experience': '',389 }...

Full Screen

Full Screen

test_category.py

Source:test_category.py Github

copy

Full Screen

...8 @classmethod9 def setup_class(cls):10 CategoryModel.objects.delete()11 @pytest.mark.run(before='test_post_categories')12 def test_get_empty(self, client):13 response = client.get("/api/category/")14 data = json.loads(response.data)15 assert isinstance(data, list)16 assert len(data) == 017 def test_post_no_data(self, client):18 response = client.post("/api/category/")19 assert response.status_code == 40020 @pytest.mark.run(after="test_get_empty")21 def test_post_categories(self, client):22 global category1_id, category2_id, category3_id23 # Category 1 Test24 data = {25 "name": "test1"26 }...

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 autotest 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