Exemplo n.º 1
0
    def test_sync_db_and_registry(self):
        def check():
            views._sync_db_and_registry(qs, 1)
            assert qs.count() == len(registry)
            modules = qs.values_list('module', flat=True)
            assert set(modules) == set(registry.keys())

        qs = DiscoveryModule.objects.no_cache().filter(app=1)
        assert qs.count() == 0

        # All our modules get added.
        check()

        # The deleted module is removed.
        with mock.patch.dict(registry):
            registry.popitem()
            check()
Exemplo n.º 2
0
    def test_sync_db_and_registry(self):
        def check():
            views._sync_db_and_registry(qs, 1)
            assert qs.count() == len(registry)
            modules = qs.values_list('module', flat=True)
            assert set(modules) == set(registry.keys())

        qs = DiscoveryModule.objects.no_cache().filter(app=1)
        assert qs.count() == 0

        # All our modules get added.
        check()

        # The deleted module is removed.
        with mock.patch.dict(registry):
            registry.popitem()
            check()