Exemplo n.º 1
0
def simple_strategy_update(simple_strategy_update_fake_column):
    return UpdateColumnsTableStrategy("update_table_where_3", [
        UniqueEmailUpdateColumnStrategy("column1", where="BANANAS < 5"),
        UniqueLoginUpdateColumnStrategy("column2", where="BANANAS < 5"),
        simple_strategy_update_fake_column,
        EmptyUpdateColumnStrategy("column4")
    ])
Exemplo n.º 2
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()
Exemplo n.º 3
0
def test_ulogin_where():
    ulogin_where = UniqueLoginUpdateColumnStrategy(column_name="column_name",
                                                   where="`cheese` = 'edam'")

    assert ulogin_where.strategy_type == UpdateColumnStrategyTypes.UNIQUE_LOGIN
    assert ulogin_where.where_condition == "`cheese` = 'edam'"
Exemplo n.º 4
0
def test_ulogin():
    ulogin = UniqueLoginUpdateColumnStrategy(column_name="column_name")

    assert ulogin.strategy_type == UpdateColumnStrategyTypes.UNIQUE_LOGIN
    assert ulogin.where_condition == None
Exemplo n.º 5
0
def ulogin_strategy():
    return UniqueLoginUpdateColumnStrategy("test_column4")
Exemplo n.º 6
0
def unsupported_column_strategy():
    column = UniqueLoginUpdateColumnStrategy("column_name")
    column.strategy_type = "NOT_SUPPORTED"

    return column