How to use disallow_unknown_tags method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

metadatapolicy.py

Source:metadatapolicy.py Github

copy

Full Screen

...55 self._tags[tag_name] = {56 "on_test": on_test,57 "on_suite": on_suite58 }59 def disallow_unknown_tags(self):60 """61 Disallow unknown tags for tests and suites.62 """63 self._disallow_unknown_tags = True64 def _check_compliance(self, obj, obj_type,65 available_properties, forbidden_properties,66 available_tags, forbidden_tags):67 # check unknown properties68 if self._disallow_unknown_properties:69 for property_name in obj.properties.keys():70 if property_name not in available_properties:71 help_msg = "available are %s" % ", ".join(map(repr, available_properties.keys())) \72 if available_properties else "no property is available"73 raise MetadataPolicyViolation(...

Full Screen

Full Screen

test_metadata_policy.py

Source:test_metadata_policy.py Github

copy

Full Screen

...64 policy = MetadataPolicy()65 policy.add_property_rule("foo", on_test=True, on_suite=True)66 policy.add_tag_rule(["tag1", "tag2"], on_test=True, on_suite=True)67 policy.disallow_unknown_properties()68 policy.disallow_unknown_tags()69 policy.check_test_compliance(suite.get_tests()[0])70 policy.check_suite_compliance(suite)71 # non-passing case72 policy = MetadataPolicy()73 policy.add_property_rule("bar", on_test=True, on_suite=True)74 policy.add_tag_rule(["tag3"], on_test=True, on_suite=True)75 policy.disallow_unknown_properties()76 policy.disallow_unknown_tags()77 with pytest.raises(MetadataPolicyViolation):78 policy.check_test_compliance(suite.get_tests()[0])79 with pytest.raises(MetadataPolicyViolation):80 policy.check_suite_compliance(suite)81def test_different_test_and_suite_property_configurations():82 @lcc.prop("foo", "1")83 @lcc.suite("MySuite")84 class MySuite:85 @lcc.prop("bar", "2")86 @lcc.test("Some test")87 def sometest(self):88 pass89 suite = load_suite_from_class(MySuite)90 # passing case91 policy = MetadataPolicy()92 policy.add_property_rule("foo", on_suite=True)93 policy.add_property_rule("bar", on_test=True)94 policy.check_test_compliance(suite.get_tests()[0])95 policy.check_suite_compliance(suite)96 # non-passing case97 policy = MetadataPolicy()98 policy.add_property_rule("foo", on_test=True)99 policy.add_property_rule("bar", on_suite=True)100 with pytest.raises(MetadataPolicyViolation):101 policy.check_test_compliance(suite.get_tests()[0])102 with pytest.raises(MetadataPolicyViolation):103 policy.check_suite_compliance(suite)104def test_different_test_and_suite_tag_configurations():105 @lcc.tags("tag1")106 @lcc.suite("MySuite")107 class MySuite:108 @lcc.tags("tag2")109 @lcc.test("Some test")110 def sometest(self):111 pass112 suite = load_suite_from_class(MySuite)113 # passing case114 policy = MetadataPolicy()115 policy.add_tag_rule("tag1", on_suite=True)116 policy.add_tag_rule("tag2", on_test=True)117 policy.check_test_compliance(suite.get_tests()[0])118 policy.check_suite_compliance(suite)119 # non-passing case120 policy = MetadataPolicy()121 policy.add_tag_rule("tag1", on_test=True)122 policy.add_tag_rule("tag2", on_suite=True)123 with pytest.raises(MetadataPolicyViolation):124 policy.check_test_compliance(suite.get_tests()[0])125 with pytest.raises(MetadataPolicyViolation):126 policy.check_suite_compliance(suite)127def test_disallow_unknown_property():128 @lcc.prop("foo", "1")129 @lcc.suite("MySuite")130 class MySuite:131 @lcc.prop("bar", "2")132 @lcc.test("Some test")133 def sometest(self):134 pass135 suite = load_suite_from_class(MySuite)136 # passing case137 policy = MetadataPolicy()138 policy.check_test_compliance(suite.get_tests()[0])139 policy.check_suite_compliance(suite)140 # non-passing case141 policy = MetadataPolicy()142 policy.disallow_unknown_properties()143 with pytest.raises(MetadataPolicyViolation):144 policy.check_test_compliance(suite.get_tests()[0])145 with pytest.raises(MetadataPolicyViolation):146 policy.check_suite_compliance(suite)147def test_disallow_unknown_tag():148 @lcc.tags("tag1")149 @lcc.suite("MySuite")150 class MySuite:151 @lcc.tags("tag2")152 @lcc.test("Some test")153 def sometest(self):154 pass155 suite = load_suite_from_class(MySuite)156 # passing case157 policy = MetadataPolicy()158 policy.check_test_compliance(suite.get_tests()[0])159 policy.check_suite_compliance(suite)160 # non-passing case161 policy = MetadataPolicy()162 policy.disallow_unknown_tags()163 with pytest.raises(MetadataPolicyViolation):164 policy.check_test_compliance(suite.get_tests()[0])165 with pytest.raises(MetadataPolicyViolation):...

Full Screen

Full Screen

test_cmd_utils.py

Source:test_cmd_utils.py Github

copy

Full Screen

...35 pass36 class MyProject(Project):37 def __init__(self, project_dir):38 Project.__init__(self, project_dir)39 self.metadata_policy.disallow_unknown_tags()40 def load_suites(self):41 return [load_suite_from_class(mysuite)]42 project = MyProject(tmpdir.strpath)43 with pytest.raises(MetadataPolicyViolation):44 load_suites_from_project(project)45def test_load_suites_from_project_with_metadata_policy_ok(tmpdir):46 @lcc.suite("My Suite")47 class mysuite:48 @lcc.test("My Test")49 def test(self):50 pass51 class MyProject(Project):52 def __init__(self, project_dir):53 Project.__init__(self, project_dir)54 self.metadata_policy.disallow_unknown_tags()55 def load_suites(self):56 return [load_suite_from_class(mysuite)]57 project = MyProject(tmpdir.strpath)...

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