How to use test_mapping method in Molotov

Best Python code snippet using molotov_python

update_crate_tests.py

Source:update_crate_tests.py Github

copy

Full Screen

...185 tests = self.package.get_rdep_tests()186 if not bool(tests):187 return188 test_mapping = self.tests_to_mapping(tests)189 self.write_test_mapping(test_mapping)190 def tests_to_mapping(self, tests):191 """Translate the test list into a dictionary."""192 test_mapping = {"presubmit": []}193 for test in tests:194 if test in TEST_EXCLUDE:195 continue196 if test in TEST_OPTIONS:197 test_mapping["presubmit"].append({"name": test, "options": TEST_OPTIONS[test]})198 else:199 test_mapping["presubmit"].append({"name": test})200 test_mapping["presubmit"] = sorted(test_mapping["presubmit"], key=lambda t: t["name"])201 return test_mapping202 def write_test_mapping(self, test_mapping):203 """Writes the TEST_MAPPING file."""204 with open("TEST_MAPPING", "w") as json_file:205 json_file.write("// Generated by update_crate_tests.py for tests that depend on this crate.\n")206 json.dump(test_mapping, json_file, indent=2, separators=(',', ': '), sort_keys=True)207 json_file.write("\n")208 print("TEST_MAPPING successfully updated for %s!" % self.package.dir_rel)209def parse_args():210 parser = argparse.ArgumentParser('update_crate_tests')211 parser.add_argument('paths',212 nargs='*',213 help='Absolute or relative paths of the projects as globs.')214 parser.add_argument('--branch_and_commit',215 action='store_true',216 help='Starts a new branch and commit changes.')...

Full Screen

Full Screen

test_inventory.py

Source:test_inventory.py Github

copy

Full Screen

1from collections import OrderedDict2from opsy.inventory.schema import (3 ZoneSchema, ZoneQuerySchema, ZoneRefSchema,4 HostSchema, HostQuerySchema, HostRefSchema,5 GroupSchema, GroupQuerySchema, GroupRefSchema,6 HostGroupMappingSchema, HostGroupMappingQuerySchema,7 HostGroupMappingRefSchema)8from opsy.inventory.models import HostGroupMapping9###############################################################################10# ZoneSchema Tests11###############################################################################12def test_zone_schema(test_zone, test_zones):13 expected_zone_schema_output = OrderedDict([14 ('id', test_zone.id),15 ('name', test_zone.name),16 ('description', test_zone.description),17 ('vars', test_zone.vars),18 ('created_at', test_zone.created_at.isoformat()),19 ('updated_at', test_zone.updated_at.isoformat()),20 ('_links', {21 'self': f'/api/v1/zones/{test_zone.id}',22 'collection': '/api/v1/zones/'})])23 expected_zone_schema_input = OrderedDict([24 ('name', 'mytestzone')])25 expected_zone_ref_schema_output = OrderedDict([26 ('id', test_zone.id),27 ('name', test_zone.name),28 ('_links', {29 'self': f'/api/v1/zones/{test_zone.id}',30 'collection': '/api/v1/zones/'})])31 expected_zone_query_schema_output = OrderedDict([32 ('name', 'mytestzone')])33 assert ZoneSchema().dump(test_zone) == expected_zone_schema_output34 assert ZoneSchema().load(35 {'name': 'mytestzone'}) == expected_zone_schema_input36 assert ZoneRefSchema().dump(test_zone) == expected_zone_ref_schema_output37 assert ZoneQuerySchema(partial=True).dump(38 {'name': 'mytestzone'}) == expected_zone_query_schema_output39###############################################################################40# HostSchema Tests41###############################################################################42def test_host_schema(test_host, test_hosts):43 expected_host_schema_output = OrderedDict([44 ('id', test_host.id),45 ('zone_id', test_host.zone_id),46 ('name', test_host.name),47 ('vars', None),48 ('compiled_vars', {}),49 ('zone', OrderedDict([50 ('id', test_host.zone.id),51 ('name', test_host.zone.name),52 ('_links', {'self': f'/api/v1/zones/{test_host.zone_id}',53 'collection': '/api/v1/zones/'})])),54 ('group_mappings', []),55 ('created_at', test_host.created_at.isoformat()),56 ('updated_at', test_host.updated_at.isoformat()),57 ('_links',58 {'self': f'/api/v1/hosts/{test_host.id}',59 'collection': '/api/v1/hosts/'})])60 expected_host_schema_input = OrderedDict([61 ('zone_id', test_host.zone_id),62 ('name', 'mytesthost')])63 expected_host_ref_schema_output = OrderedDict([64 ('id', test_host.id),65 ('name', test_host.name),66 ('_links', {67 'self': f'/api/v1/hosts/{test_host.id}',68 'collection': '/api/v1/hosts/'})])69 expected_host_query_schema_output = OrderedDict([70 ('name', 'mytesthost')])71 assert HostSchema().dump(test_host) == expected_host_schema_output72 assert HostSchema().load(73 {'name': 'mytesthost',74 'zone_id': test_host.zone_id}) == expected_host_schema_input75 assert HostRefSchema().dump(test_host) == expected_host_ref_schema_output76 assert HostQuerySchema(partial=True).dump(77 {'name': 'mytesthost'}) == expected_host_query_schema_output78###############################################################################79# GroupSchema Tests80###############################################################################81def test_group_schema(test_group, test_groups):82 expected_group_schema_output = OrderedDict([83 ('id', test_group.id),84 ('zone_id', test_group.zone_id),85 ('parent_id', test_group.parent_id),86 ('name', test_group.name),87 ('default_priority', test_group.default_priority),88 ('vars', test_group.vars),89 ('compiled_vars', test_group.compiled_vars),90 ('created_at', test_group.created_at.isoformat()),91 ('updated_at', test_group.updated_at.isoformat()),92 ('_links',93 {'self': f'/api/v1/groups/{test_group.id}',94 'collection': '/api/v1/groups/'})])95 expected_group_schema_input = OrderedDict([96 ('name', 'mytestgroup')])97 expected_group_ref_schema_output = OrderedDict([98 ('id', test_group.id),99 ('name', test_group.name),100 ('_links', {101 'self': f'/api/v1/groups/{test_group.id}',102 'collection': '/api/v1/groups/'})])103 expected_group_query_schema_output = OrderedDict([104 ('name', 'mytestgroup')])105 assert GroupSchema().dump(test_group) == expected_group_schema_output106 assert GroupSchema().load(107 {'name': 'mytestgroup'}) == expected_group_schema_input108 assert GroupRefSchema().dump(test_group) == expected_group_ref_schema_output109 assert GroupQuerySchema(partial=True).dump(110 {'name': 'mytestgroup'}) == expected_group_query_schema_output111###############################################################################112# HostGroupMappingSchema Tests113###############################################################################114def test_host_group_mapping_schema(test_inventory_bootstrap):115 test_mapping = HostGroupMapping.get_by_host_and_group(116 'westprom', 'prom_nodes')117 expected_host_group_mapping_schema_output = OrderedDict([118 ('id', test_mapping.id),119 ('host_id', test_mapping.host_id),120 ('group_id', test_mapping.group_id),121 ('priority', test_mapping.priority),122 ('host', OrderedDict([123 ('id', test_mapping.host.id),124 ('name', test_mapping.host.name),125 ('_links',126 {'self': f'/api/v1/hosts/{test_mapping.host.id}',127 'collection': '/api/v1/hosts/'})])),128 ('group', OrderedDict([129 ('id', test_mapping.group.id),130 ('name', test_mapping.group.name),131 ('_links',132 {'self': f'/api/v1/groups/{test_mapping.group.id}',133 'collection': '/api/v1/groups/'})])),134 ('created_at', test_mapping.created_at.isoformat()),135 ('updated_at', test_mapping.updated_at.isoformat()),136 ('_links',137 {'self': f'/api/v1/hosts/{test_mapping.host.id}'138 f'/group_mappings/{test_mapping.group.id}',139 'collection': f'/api/v1/hosts/{test_mapping.host.id}'140 '/group_mappings/'})])141 expected_host_group_mapping_ref_schema_output = OrderedDict([142 ('id', test_mapping.id),143 ('host_id', test_mapping.host_id),144 ('host_name', test_mapping.host_name),145 ('group_id', test_mapping.group_id),146 ('group_name', test_mapping.group_name),147 ('priority', test_mapping.priority),148 ('_links',149 {'self': f'/api/v1/hosts/{test_mapping.host.id}'150 f'/group_mappings/{test_mapping.group.id}',151 'collection': f'/api/v1/hosts/{test_mapping.host.id}'152 '/group_mappings/'})])153 expected_host_group_mapping_query_schema_output = OrderedDict([154 ('group_name', 'mytestmapping')])155 assert HostGroupMappingSchema().dump(test_mapping) == \156 expected_host_group_mapping_schema_output157 assert HostGroupMappingRefSchema().dump(test_mapping) == \158 expected_host_group_mapping_ref_schema_output159 assert HostGroupMappingQuerySchema().dump(160 {'group___name': 'mytestmapping'}) == \...

Full Screen

Full Screen

common.py

Source:common.py Github

copy

Full Screen

1#media sources2dataurl_src = "'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQAAAAAAAAA'"3throttler = "'/core/standards/web-apps/media/network/range-request-log/range-request.php?rate=100000&fileloc=";4mp4_src = throttler + "../../support/preload.mp4&nocache=' + Math.random()";5ogg_src = throttler + "../../support/preload.ogv&nocache=' + Math.random()";6webm_src = throttler + "../../support/preload.webm&nocache=' + Math.random()";7metadata_networkstate_order = "eval('/^(' + HTMLMediaElement.NETWORK_LOADING + ' )+(' + HTMLMediaElement.NETWORK_IDLE + ' )+$/g')"8metadata_networkstate_order_dataurl = "eval('/^(' + HTMLMediaElement.NETWORK_IDLE + ' )+$/g')"9metadata_readystate_order = "eval('/^(' + HTMLMediaElement.HAVE_NOTHING + ' )+' + HTMLMediaElement.HAVE_METADATA + '(' + HTMLMediaElement.HAVE_CURRENT_DATA + ' )+$/g')"10metadata_readystate_order_dataurl = "eval('/^(' + HTMLMediaElement.HAVE_NOTHING + ' )+(' + HTMLMediaElement.HAVE_ENOUGH_DATA + ' )+$/g')"11timeout = 1000012timeout_dataurl = 500013testsuite = {14 '*' : [15 {'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'timeout' : timeout_dataurl}},16 {'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'timeout' : timeout}},17 {'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'timeout' : timeout}},18 {'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'timeout' : timeout}}19 ],20 'preload-metadata-networkstate-order.tpl' : [21 {'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'states_expected' : metadata_networkstate_order_dataurl, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout_dataurl}},22 {'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'states_expected' : metadata_networkstate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},23 {'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'states_expected' : metadata_networkstate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},24 {'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'states_expected' : metadata_networkstate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}}25 ],26 'preload-metadata-readystate-order.tpl' : [27 {'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'states_expected' : metadata_readystate_order_dataurl, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout_dataurl}},28 {'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'states_expected' : metadata_readystate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},29 {'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'states_expected' : metadata_readystate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},30 {'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'states_expected' : metadata_readystate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}}31 ]...

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