コード例 #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()))
コード例 #2
0
 def handle(self, **options):
     logger.setLevel('DEBUG')
     domains = [row['key'] for row in Domain.get_all(include_docs=False)]
     settings = {
         s['id']: s['default']
         for s in get_custom_commcare_settings() if 'default' in s
     }
     deviant_counts = {id: 0 for id in settings.keys()}
     app_count = 0
     for domain in domains:
         for app in get_apps_in_domain(domain, include_remote=False):
             #logger.info("looking at app {}".format(app.id))
             if ('properties' in app.profile):
                 app_count = app_count + 1
                 for id, default in six.iteritems(settings):
                     if (id not in app.profile['properties']):
                         #logger.info("{}: not found".format(id))
                         pass
                     elif (app.profile['properties'][id] != default):
                         #logger.info("{}: {} != {}".format(id, app.profile['properties'][id], default))
                         deviant_counts[id] = deviant_counts[id] + 1
                     else:
                         #logger.info("{}: {} == {}".format(id, app.profile['properties'][id], default))
                         pass
     for id, count in six.iteritems(deviant_counts):
         logger.info("{}\t{}".format(count, id))
     logger.info(
         'done with audit_app_profile_properties, examined {} apps in {} domains'
         .format(app_count, len(domains)))
コード例 #3
0
    def test_profile_properties(self):
        for setting in get_custom_commcare_settings():
            if setting['id'] == 'users':
                continue
            for value in setting.get('values', []):
                self.app.profile = {setting['type']: {setting['id']: value}}
                self._test_profile(self.app)

        # custom properties do not rely on SETTINGS so need to be tested separately
        self.app.profile = {'custom_properties': {'random': 'value'}}
        profile = self.app.create_profile()
        self._test_profile(self.app)
        self._test_custom_property(ET.fromstring(profile), 'random', 'value')
コード例 #4
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()))
コード例 #5
0
    def test_profile_properties(self):
        for setting in get_custom_commcare_settings():
            if setting['id'] == 'users':
                continue
            for value in setting.get('values', []):
                self.app.profile = {
                    setting['type']: {
                        setting['id']: value
                    }
                }
                self._test_profile(self.app)

        # custom properties do not rely on SETTINGS so need to be tested separately
        self.app.profile = {
            'custom_properties': {
                'random': 'value'
            }
        }
        profile = self.app.create_profile()
        self._test_profile(self.app)
        self._test_custom_property(ET.fromstring(profile), 'random', 'value')
コード例 #6
0
 def handle(self, *args, **options):
     domains = [row['key'] for row in Domain.get_all(include_docs=False)]
     settings = {s['id']: s['default'] for s in get_custom_commcare_settings() if 'default' in s}
     deviant_counts = {id: 0 for id in settings.keys()}
     app_count = 0
     for domain in domains:
         for app in get_apps_in_domain(domain, include_remote=False):
             #logger.info("looking at app {}".format(app.id))
             if ('properties' in app.profile):
                 app_count = app_count + 1
                 for id, default in settings.iteritems():
                     if (id not in app.profile['properties']):
                         #logger.info("{}: not found".format(id))
                         pass
                     elif (app.profile['properties'][id] != default):
                         #logger.info("{}: {} != {}".format(id, app.profile['properties'][id], default))
                         deviant_counts[id] = deviant_counts[id] + 1
                     else:
                         #logger.info("{}: {} == {}".format(id, app.profile['properties'][id], default))
                         pass
     for id, count in deviant_counts.iteritems():
         logger.info("{}\t{}".format(count, id))
     logger.info('done with audit_app_profile_properties, examined {} apps in {} domains'.format(app_count, len(domains)))
コード例 #7
0
ファイル: reports.py プロジェクト: ekush/commcare-hq
 def profile_list(self):
     return [
         "profile.%s.%s" % (c['type'], c['id'])
         for c in get_custom_commcare_settings() if c['type'] != 'hq'
     ]
コード例 #8
0
 def profile_list(self):
     return [
         "profile.%s.%s" % (c['type'], c['id'])
         for c in get_custom_commcare_settings() if c['type'] != 'hq'
     ]