def test_one_doesnt_exist(self, test_app_context, fixture_colony_a, fixture_colony_b): connection = get_redis_db_from_context() a = fixture_colony_a b = fixture_colony_b self.setup_data_in_db(a, connection) self.setup_data_in_db(b, connection) c = Colony.from_dict( { 'BaseName': 'TestColonyC', 'FactionName': 'TestFactionC', 'Planet': 'TestPlanetC', 'Hash': 'EFGH', 'OwnerType': 'Normal', 'OwnerID': 1 }, connection=db.get_redis_db_from_context()) colony_data = [a.to_dict(), b.to_dict(), c.to_dict()] result = list( Colony.get_many_from_database( colony_data, db.get_redis_db_from_context()).values()) assert len(result) == 3 assert result[0].BaseName == a.BaseName and result[0].FromDatabase assert result[1].BaseName == b.BaseName and result[1].FromDatabase assert result[2].BaseName == c.BaseName and not result[2].FromDatabase
def test_all_none(self, test_app_context): """ Test that none of these entries exist in the DB, Assert that all results have FromDatabase == False :param test_app_context: :return: """ a = Colony.from_dict( { 'BaseName': 'TestColonyA', 'FactionName': 'TestFactionA', 'Planet': 'TestPlanetA', 'Hash': '1234', 'OwnerType': 'Normal', 'OwnerID': 1 }, connection=db.get_redis_db_from_context()) b = Colony.from_dict( { 'BaseName': 'TestColonyB', 'FactionName': 'TestFactionB', 'Planet': 'TestPlanetB', 'Hash': '5678', 'OwnerType': 'Normal', 'OwnerID': 1 }, connection=db.get_redis_db_from_context()) c = Colony.from_dict( { 'BaseName': 'TestColonyC', 'FactionName': 'TestFactionC', 'Planet': 'TestPlanetC', 'Hash': 'EFGH', 'OwnerType': 'Normal', 'OwnerID': 1 }, connection=db.get_redis_db_from_context()) colony_data = [a.to_dict(), b.to_dict(), c.to_dict()] result = Colony.get_many_from_database(colony_data, db.get_redis_db_from_context()) s = list(zip(colony_data, result.values())) assert len(s) == 3 for a, b in s: assert not b.FromDatabase
def test_all_exist(self, test_app_context, fixture_colony_a, fixture_colony_b, fixture_colony_steam): connection = get_redis_db_from_context() a = fixture_colony_a b = fixture_colony_b c = fixture_colony_steam self.setup_data_in_db(a, connection) self.setup_data_in_db(b, connection) self.setup_data_in_db(c, connection) colony_data = [a.to_dict(), b.to_dict(), c.to_dict()] result = Colony.get_many_from_database(colony_data, db.get_redis_db_from_context()) s = zip(colony_data, result.values()) for a, b in s: assert a['BaseName'] == b.BaseName and b.FromDatabase