예제 #1
0
    def __call__(self, restore_user, version, last_sync=None, app=None):
        assert isinstance(restore_user, OTARestoreUser)

        domain = restore_user.project
        fixtures = []

        if self._should_return_no_fixtures(domain, last_sync):
            return fixtures

        config = None
        if app:
            try:
                config = get_call_center_config_from_app(app)
            except:
                notify_exception(None, "Error getting call center config from app", details={
                    'domain': app.domain,
                    'app_id': app.get_id
                })

        if config:
            _assert = soft_assert(['skelly_at_dimagi_dot_com'.replace('_at_', '@').replace('_dot_', '.')])
            _assert(not config.includes_legacy(), 'Domain still using legacy call center indicators', {
                'domain': domain,
                'config': config.to_json()
            })

        try:
            fixtures.append(gen_fixture(restore_user, restore_user.get_call_center_indicators(config)))
        except Exception:  # blanket exception catching intended
            notify_exception(None, 'problem generating callcenter fixture', details={
                'user_id': restore_user.user_id,
                'domain': restore_user.domain
            })

        return fixtures
def test_get_config_from_app_bad_names(self, indicators, expected):
    app = self._get_app()
    app.domain = "infomovel"
    self._add_indicators_to_module_details(app.get_module(0), indicators=indicators)
    config = get_call_center_config_from_app(app)
    indicators_from_config = get_indicator_slugs_from_config(config)
    self.assertEqual(sorted(indicators_from_config), expected)
예제 #3
0
    def __call__(self, restore_user, version, last_sync=None, app=None):
        assert isinstance(restore_user, OTARestoreUser)

        domain = restore_user.project
        fixtures = []

        if self._should_return_no_fixtures(domain, last_sync):
            return fixtures

        config = None
        if app:
            try:
                config = get_call_center_config_from_app(app)
            except:
                notify_exception(None, "Error getting call center config from app", details={
                    'domain': app.domain,
                    'app_id': app.get_id
                })

        if config:
            _assert = soft_assert(['skelly_at_dimagi_dot_com'.replace('_at_', '@').replace('_dot_', '.')])
            _assert(not config.includes_legacy(), 'Domain still using legacy call center indicators', {
                'domain': domain,
                'config': config.to_json()
            })

        try:
            fixtures.append(gen_fixture(restore_user, restore_user.get_call_center_indicators(config)))
        except Exception:  # blanket exception catching intended
            notify_exception(None, 'problem generating callcenter fixture', details={
                'user_id': restore_user.user_id,
                'domain': restore_user.domain
            })

        return fixtures
def test_get_config_from_app_bad_names(self, indicators, expected):
    app = self._get_app()
    app.domain = 'infomovel'
    self._add_indicators_to_module_details(app.get_module(0),
                                           indicators=indicators)
    config = get_call_center_config_from_app(app)
    indicators_from_config = get_indicator_slugs_from_config(config)
    self.assertEqual(sorted(indicators_from_config), expected)
예제 #5
0
def update_callcenter_config(sender, application, **kwargs):
    if not application.copy_of:
        return

    try:
        domain_obj = Domain.get_by_name(application.domain)
        cc_config = domain_obj.call_center_config
        if not cc_config or not (cc_config.fixtures_are_active() and cc_config.config_is_valid()):
            return

        app_config = get_call_center_config_from_app(application)
        save = cc_config.update_from_app_config(app_config)
        if save:
            cc_config.save()
    except Exception:
        notify_exception(None, "Error updating CallCenter config for app build")
 def test_get_config_from_app(self):
     app = self._get_app()
     app.domain = 'aarohi'
     self._add_indicators_to_module_details(app.get_module(0),
                                            self.test_indicators[0:2])
     self._add_indicators_to_module_details(app.get_module(1),
                                            self.test_indicators[2:4])
     forms = list(app.get_forms(bare=True))
     self._add_indicators_to_form(forms[2], self.test_indicators[4:])
     config = get_call_center_config_from_app(app)
     indicators_from_config = get_indicator_slugs_from_config(config)
     expected = self.test_indicators
     expected = sorted(
         # these get added becuase legacy indicators just use the date ranges for the
         # new indicator names
         expected + ['formsSubmittedMonth1', 'forms_submitted_week0'])
     self.assertEqual(sorted(indicators_from_config), expected)
 def test_get_config_from_app(self):
     app = self._get_app()
     app.domain = "aarohi"
     self._add_indicators_to_module_details(app.get_module(0), self.test_indicators[0:2])
     self._add_indicators_to_module_details(app.get_module(1), self.test_indicators[2:4])
     forms = list(app.get_forms(bare=True))
     self._add_indicators_to_form(forms[2], self.test_indicators[4:])
     config = get_call_center_config_from_app(app)
     indicators_from_config = get_indicator_slugs_from_config(config)
     expected = self.test_indicators
     expected = sorted(
         # these get added becuase legacy indicators just use the date ranges for the
         # new indicator names
         expected
         + ["formsSubmittedMonth1", "forms_submitted_week0"]
     )
     self.assertEqual(sorted(indicators_from_config), expected)
예제 #8
0
def update_callcenter_config(sender, application, **kwargs):
    if not application.copy_of:
        return

    try:
        domain_obj = Domain.get_by_name(application.domain)
        cc_config = domain_obj.call_center_config
        if not cc_config or not (cc_config.fixtures_are_active()
                                 and cc_config.config_is_valid()):
            return

        app_config = get_call_center_config_from_app(application)
        save = cc_config.update_from_app_config(app_config)
        if save:
            cc_config.save()
    except Exception:
        notify_exception(None,
                         "Error updating CallCenter config for app build")