def __parse_update_column(self, column_config): update_column_type = UpdateColumnStrategyTypes.from_value( column_config.pop("type")) try: if update_column_type == UpdateColumnStrategyTypes.EMPTY: return EmptyUpdateColumnStrategy(**column_config) elif update_column_type == UpdateColumnStrategyTypes.UNIQUE_LOGIN: return UniqueLoginUpdateColumnStrategy(**column_config) elif update_column_type == UpdateColumnStrategyTypes.UNIQUE_EMAIL: return UniqueEmailUpdateColumnStrategy(**column_config) elif update_column_type == UpdateColumnStrategyTypes.FAKE_UPDATE: return FakeUpdateColumnStrategy( fake_column_generator=self.fake_seeder, **column_config) elif update_column_type == UpdateColumnStrategyTypes.LITERAL: return LiteralUpdateColumnStrategy(**column_config) else: raise UnknownColumnStrategyError(column_config) except TypeError as error: # TypeError can be thrown when the dict args dont match the constructors for the types. We need to re-throw raise ConfigSyntaxError()
def test_fake_update(): fake_column_generator = Mock() fake_update = FakeUpdateColumnStrategy( column_name="column_name", fake_column_generator=fake_column_generator, fake_type="company_email") assert fake_update.strategy_type == UpdateColumnStrategyTypes.FAKE_UPDATE assert fake_update.value == fake_column_generator.get_value( "company_email") assert fake_update.data_type == fake_column_generator.get_data_type( "company_email") assert fake_update.fake_type == "company_email"
def test_fake_update_where(): fake_column_generator = Mock() fake_update_where = FakeUpdateColumnStrategy( column_name="column_name", fake_column_generator=fake_column_generator, fake_type="company_email", where="chickens = 1", ) assert fake_update_where.strategy_type == UpdateColumnStrategyTypes.FAKE_UPDATE assert fake_update_where.value == fake_column_generator.get_value( "company_email") assert fake_update_where.data_type == fake_column_generator.get_data_type( "company_email") assert fake_update_where.fake_type == "company_email" assert fake_update_where.where_condition == "chickens = 1"
def simple_strategy_update_fake_column(simple_strategy_fake_generator): return FakeUpdateColumnStrategy("column3", simple_strategy_fake_generator, "user_name", where="BANANAS < 3")
def fake_update_column_int_last_name(int_fake_column_generator): return FakeUpdateColumnStrategy("test_column2", int_fake_column_generator, "last_name")
def fake_update_column_str_first_name(str_fake_column_generator): return FakeUpdateColumnStrategy("test_column1", str_fake_column_generator, "first_name")
def fake_update_column_uuid_user_id(uuid_fake_column_generator): return FakeUpdateColumnStrategy("test_column7", uuid_fake_column_generator, "user_id", sql_type="UUID")