Exemple #1
0
    def test_fail_when_model_is_abstract(self):
        class Meta:
            abstract = True

        with pytest.raises(errors.PolyjuiceError) as err:
            meta.build_meta_class(self.table, Meta)

        assert err.value.args[0] == "You cannot mimic an abstract model."
Exemple #2
0
    def test_fail_when_db_table_field_is_overriden(self):
        class Meta:
            db_table = "my_custom_name"

        with pytest.raises(errors.PolyjuiceError) as err:
            meta.build_meta_class(self.table, Meta)

        assert err.value.args[0] == "You cannot override Meta.db_table field."
Exemple #3
0
    def test_fail_when_indexes_field_is_overriden(self):
        class Meta:
            indexes = [models.Index(name="bad_index", fields=["some_field"])]

        Index("my_super_index", self.table.c.name)

        with pytest.raises(errors.PolyjuiceError) as err:
            meta.build_meta_class(self.table, Meta)

        assert err.value.args[0] == "You cannot override Meta.indexes field."
Exemple #4
0
    def test_indexes(self):
        Index("my_super_index", self.table.c.name)

        Meta = meta.build_meta_class(self.table, self.user_defined_meta)

        assert len(Meta.indexes) == 1
Exemple #5
0
    def test_db_table(self):
        Meta = meta.build_meta_class(self.table, self.user_defined_meta)

        assert Meta.db_table == "test_table"