예제 #1
0
    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()
예제 #2
0
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"
예제 #3
0
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"
예제 #4
0
def simple_strategy_update_fake_column(simple_strategy_fake_generator):
    return FakeUpdateColumnStrategy("column3",
                                    simple_strategy_fake_generator,
                                    "user_name",
                                    where="BANANAS < 3")
예제 #5
0
def fake_update_column_int_last_name(int_fake_column_generator):
    return FakeUpdateColumnStrategy("test_column2", int_fake_column_generator,
                                    "last_name")
예제 #6
0
def fake_update_column_str_first_name(str_fake_column_generator):
    return FakeUpdateColumnStrategy("test_column1", str_fake_column_generator,
                                    "first_name")
예제 #7
0
def fake_update_column_uuid_user_id(uuid_fake_column_generator):
    return FakeUpdateColumnStrategy("test_column7",
                                    uuid_fake_column_generator,
                                    "user_id",
                                    sql_type="UUID")