Example #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'])
Example #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'])
Example #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'])
Example #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'])
Example #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'])
Example #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()
Example #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'])
Example #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'])
Example #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()
Example #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'])