Exemplo n.º 1
0
    def test_has_and_belongs_to_many(self):
        class Bear(Model):
            has_and_belongs_to_many = ('Continent',)

        assert index_registry.get_for_model('Bear') == set()
        assert index_registry.get_for_model('Continent') == set()
        assert index_registry.get_for_model('_BearContinent') == set(['bear_id', 'continent_id'])
Exemplo n.º 2
0
    def test_has_and_belongs_to_many(self):
        class Bear(Model):
            has_and_belongs_to_many = ('Continent', )

        assert index_registry.get_for_model('Bear') == set()
        assert index_registry.get_for_model('Continent') == set()
        assert index_registry.get_for_model('_BearContinent') == set(
            ['bear_id', 'continent_id'])
Exemplo n.º 3
0
    def test_all_relations(self):
        class Bear(Model):
            has_one = ('FavoriteCub',)
            belongs_to = ('Family',)
            has_many = ('Cub',)
            has_and_belongs_to_many = ('Continent',)

        assert index_registry.get_for_model('Bear') == set(['family_id'])
        assert index_registry.get_for_model('FavoriteCub') == set(['bear_id'])
        assert index_registry.get_for_model('Family') == set()
        assert index_registry.get_for_model('Cub') == set(['bear_id'])
        assert index_registry.get_for_model('Continent') == set()
        assert index_registry.get_for_model('_BearContinent') == set(['bear_id', 'continent_id'])
Exemplo n.º 4
0
    def test_all_relations(self):
        class Bear(Model):
            has_one = ('FavoriteCub', )
            belongs_to = ('Family', )
            has_many = ('Cub', )
            has_and_belongs_to_many = ('Continent', )

        assert index_registry.get_for_model('Bear') == set(['family_id'])
        assert index_registry.get_for_model('FavoriteCub') == set(['bear_id'])
        assert index_registry.get_for_model('Family') == set()
        assert index_registry.get_for_model('Cub') == set(['bear_id'])
        assert index_registry.get_for_model('Continent') == set()
        assert index_registry.get_for_model('_BearContinent') == set(
            ['bear_id', 'continent_id'])
Exemplo n.º 5
0
    def test_has_many(self):
        class Bear(Model):
            has_many = ('Cub', )

        assert index_registry.get_for_model('Bear') == set()
        assert index_registry.get_for_model('Cub') == set(['bear_id'])
Exemplo n.º 6
0
    def test_belongs_one(self):
        class Bear(Model):
            belongs_to = ('Family', )

        assert index_registry.get_for_model('Bear') == set(['family_id'])
        assert index_registry.get_for_model('Family') == set()
Exemplo n.º 7
0
    def test_has_one(self):
        class Bear(Model):
            has_one = ('FavoriteCub', )

        assert index_registry.get_for_model('Bear') == set()
        assert index_registry.get_for_model('FavoriteCub') == set(['bear_id'])
Exemplo n.º 8
0
    def test_has_many(self):
        class Bear(Model):
            has_many = ('Cub',)

        assert index_registry.get_for_model('Bear') == set()
        assert index_registry.get_for_model('Cub') == set(['bear_id'])
Exemplo n.º 9
0
    def test_belongs_one(self):
        class Bear(Model):
            belongs_to = ('Family',)

        assert index_registry.get_for_model('Bear') == set(['family_id'])
        assert index_registry.get_for_model('Family') == set()
Exemplo n.º 10
0
    def test_has_one(self):
        class Bear(Model):
            has_one = ('FavoriteCub',)

        assert index_registry.get_for_model('Bear') == set()
        assert index_registry.get_for_model('FavoriteCub') == set(['bear_id'])