How to use assert_all_in method in Testify

Best Python code snippet using Testify_python

test_collections.py

Source:test_collections.py Github

copy

Full Screen

...43 def test_04_object_partial_fields_and_dump(self):44 p = Person(name="test", _key="12312")45 d = p._dump()46 print(d)47 self.assert_all_in(["name", "_key"], d)48 assert d["dob"] is None49 def test_05_object_load_and_dump_with_extra_fields_disabled(self):50 d = {51 "_key": "person_1",52 "name": "John Doe",53 "dob": "2016-09-12",54 "profession": "absent",55 }56 p = Person._load(d)57 assert hasattr(p, "_key")58 assert hasattr(p, "name")59 assert hasattr(p, "dob")60 assert hasattr(p, "profession") is False61 d2 = p._dump()62 self.assert_all_in(["_key", "name", "dob"], d2)63 assert "profession" not in d264 def test_06_object_load_and_dump_with_extra_fields_enabled(self):65 d = {66 "make": "Mitsubishi",67 "model": "Lancer",68 "year": 2005,69 "nickname": "Lancer Evo",70 }71 c = Car._load(d)72 assert hasattr(c, "make")73 assert hasattr(c, "model")74 assert hasattr(c, "year")75 assert hasattr(c, "nickname")76 self.assert_all_in(["make", "model", "year", "nickname"], c._dump())77 def test_07_collection_mixin(self):78 class ResultMixin(CollectionBase):79 _key = String()80 _timestamp = DateTime()81 stats = String()82 class PingResult(ResultMixin, Collection):83 __collection__ = "ping_results"84 host = String(required=True)85 status = String(required=True) # UP, DOWN, SLOW86 error_message = String()87 stats = Dict()88 self.assert_all_in(89 ["_key", "_timestamp", "host", "status", "error_message", "stats"],90 PingResult._fields,91 )92 assert (93 type(PingResult._fields["stats"]) is Dict94 ) # not String from ResultMixin95 def test_08_multi_level_collection_inheritence(self):96 class ResultMixin(CollectionBase):97 _key = String()98 _timestamp = DateTime()99 stats = String()100 class Result(ResultMixin):101 host = String(required=True)102 status = String(required=True) # UP, DOWN, SLOW103 error_message = String()104 class PingResult(Result, Collection):105 __collection__ = "ping_results"106 stats = Dict()107 print(PingResult._fields.keys())108 self.assert_all_in(109 ["_key", "_timestamp", "host", "status", "error_message", "stats"],110 PingResult._fields,111 )112 assert (113 type(PingResult._fields["stats"]) is Dict114 ) # not String from ResultMixin115 def test_09_load_from_instance_with_extra_patch_data(self):116 p = Person(117 name="test", _key="12312", dob=date(year=2016, month=9, day=12)118 )119 np = Person._load({"name": "Wonder"}, instance=p)120 assert p.name == "test"121 assert np.name == "Wonder"122 assert np._key == "12312"...

Full Screen

Full Screen

test_fill_table.py

Source:test_fill_table.py Github

copy

Full Screen

...79 required = ['source', 'changed', 'country', 'lang', 'id', 'adm0']80 for table, dataset in self.data.items():81 msg = '%s in fill_table_monuments_all ' % table82 msg += 'missing required variable(s): %s'83 self.assert_all_in(required, dataset['replaced'], msg=msg)84class TestFillTableMonumentsOntoMonumentsConfig(unittest.TestCase,85 CustomAssertions):86 """Compatibility of fill_table_monuments_all.sql with monuments_config."""87 def setUp(self):88 datasets = fill_table.get_all_dataset_sql()89 self.text = fill_table.MonumentsAllSql(datasets).get_sql()90 self.data = isolate_dataset_entries(self.text)91 self.process_config_tables()92 def process_config_tables(self):93 """Identify tables in monuments_config."""94 self.config_tables = []95 self.config_lookup = {}96 for key, data in config.countries.items():97 table = data['table']98 if table.startswith('monuments'): # i.e. not wlpa99 self.config_tables.append(table)100 self.config_lookup[table] = key101 def get_config_field_dests(self, table):102 """Return field destinations for a given table in monuments_config."""103 key = self.config_lookup[table]104 dest = []105 for field in config.countries[key].get('fields', []):106 dest.append(field['dest'])107 return dest108 def test_fill_table_monuments_all_tables_present(self):109 """Ensure all needed tables are present in monuments_config."""110 msg = '%s in fill_table_monuments_all not present in monuments_config'111 self.assert_all_in(list(self.data.keys()), self.config_tables, msg=msg)112 def test_fill_table_monuments_all_config_tables_used(self):113 """Ensure that all monuments_config tables are used."""114 msg = '%s in monuments_config not used in fill_table_monuments_all'115 self.assert_all_in(self.config_tables, list(self.data.keys()), msg=msg)116 @unittest.expectedFailure # @todo fix117 def test_fill_table_monuments_all_source_in_config(self):118 """Ensure all sources are present in the corresponding config entry."""119 for table, dataset in self.data.items():120 msg = '%s in fill_table_monuments_all ' % table121 msg += 'expects missing field(s): %s'122 dest = self.get_config_field_dests(table)123 dest += ['source', 'changed'] # implicitly defined...

Full Screen

Full Screen

client_tests.py

Source:client_tests.py Github

copy

Full Screen

...6db_client = client.DropboxClient(config['server'], config['content_server'], config['port'], dba, access_token)7root = config['root']8CALLBACK_URL = 'http://printer.example.com/request_token_ready'9RESOURCE_URL = 'http://' + config['server'] + '/0/oauth/echo'10def assert_all_in(in_list, all_list):11 assert all(item in in_list for item in all_list), "expected all items in %s to be found in %s" % (all_list, in_list)12def test_delete():13 db_client.file_delete(root, "/tohere")14 return db_client15def test_put_file():16 f = open("tests/dropbox_tests/client_tests.py")17 resp = db_client.put_file(root, "/", f)18 assert resp19 assert_equal(resp.status, 200)20 return db_client21def test_get_file():22 db_client = test_put_file()23 resp = db_client.get_file(root, "/client_tests.py")24 assert_equal(resp.status, 200)25 assert len(resp.read()) > 10026def test_account_info():27 db_client = test_delete()28 resp = db_client.account_info()29 assert resp30 assert_equal(resp.status, 200)31 assert_all_in(resp.data.keys(), [u'country', u'display_name', u'uid', u'quota_info'])32def test_fileops():33 db_client = test_delete()34 test_put_file()35 resp = db_client.file_create_folder(root, "/tohere")36 assert_equal(resp.status, 200)37 assert_all_in(resp.data.keys(), [u'thumb_exists', u'bytes', u'modified', u'path',38 u'is_dir', u'size', u'root', u'icon'])39 resp = db_client.file_copy(root, "/client_tests.py", "/tohere/client_tests.py")40 print resp.headers41 assert_equal(resp.status, 200)42 assert_all_in(resp.data.keys(), [u'thumb_exists', u'bytes', u'modified',43 u'path', u'is_dir', u'size', u'root',44 u'mime_type', u'icon'])45 resp = db_client.file_move(root, "/tohere/client_tests.py",46 "/tohere/client_tests.py.temp")47 assert_equal(resp.status, 200)48 resp = db_client.file_delete(root, "/tohere/client_tests.py.temp")49 assert_equal(resp.status, 200)50 assert_all_in(resp.data.keys(), [u'is_deleted', u'thumb_exists', u'bytes', u'modified',51 u'path', u'is_dir', u'size', u'root', u'mime_type', u'icon'])52def test_metadata():53 db_client = test_delete()54 resp = db_client.metadata(root, "/tohere")55 assert resp56 assert_equal(resp.status, 200)57 assert_all_in(resp.data.keys(), [u'is_deleted', u'thumb_exists',58 u'bytes', u'modified', u'path', u'is_dir',59 u'size', u'root', u'hash', u'contents', u'icon'])60def test_links():61 db_client = test_put_file()62 url = db_client.links(root, "/client_tests.py")63 assert_equal(url, "http://" + config['server'] + "/0/links/" + root + "/client_tests.py")64def test_thumbnails():65 db_client.file_delete(root, "/sample_photo.jpg")66 f = open("tests/sample_photo.jpg", "rb")67 resp = db_client.put_file(root, "/", f)68 assert_equal(resp.status, 200)69 resp = db_client.get_file(root, "/sample_photo.jpg")70 body = resp.read()71 assert_equal(resp.status, 200)...

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