Beispiel #1
0
    def test_circular_dependencies(self):
        def generate_lookup(settings):
            lookup = defaultdict(lambda: defaultdict(dict))
            for setting in settings:
                lookup[setting['type']][setting['id']] = setting
            return lookup

        settings1 = [
            {
                'contingent_default': [
                    {'condition': "{features.notsense}='true'", 'value': 'Yes'},
                    {'condition': "{features.sense}='true'", 'value': 'Yes'},
                ],
                'id': 'cc-login-images',
                'type': 'properties',
            },
            {
                'contingent_default': [{'condition': "{properties.server-tether}='true'", 'value': 'Yes'}],
                'id': 'sense',
                'type': 'features',
            },
            {
                'contingent_default': [{'condition': "{properties.cc-login-images}='true'", 'value': 'Yes'}],
                'id': 'server-tether',
                'type': 'properties',
            },
        ]

        self.assertTrue(circular_dependencies(settings1, generate_lookup(settings1)))
        self.assertFalse(circular_dependencies(get_custom_commcare_settings(), get_commcare_settings_lookup()))
    def test_circular_dependencies(self):
        def generate_lookup(settings):
            lookup = defaultdict(lambda: defaultdict(dict))
            for setting in settings:
                lookup[setting['type']][setting['id']] = setting
            return lookup

        settings1 = [
            {
                'contingent_default': [
                    {'condition': "{features.notsense}='true'", 'value': 'Yes'},
                    {'condition': "{features.sense}='true'", 'value': 'Yes'},
                ],
                'id': 'cc-login-images',
                'type': 'properties',
            },
            {
                'contingent_default': [{'condition': "{properties.server-tether}='true'", 'value': 'Yes'}],
                'id': 'sense',
                'type': 'features',
            },
            {
                'contingent_default': [{'condition': "{properties.cc-login-images}='true'", 'value': 'Yes'}],
                'id': 'server-tether',
                'type': 'properties',
            },
        ]

        self.assertTrue(circular_dependencies(settings1, generate_lookup(settings1)))
        self.assertFalse(circular_dependencies(SETTINGS, SETTINGS_LOOKUP))