Exemplo n.º 1
0
 def test_migration(self):
     bootstrap_domain(ILSGatewayAPI(TEST_DOMAIN, MockEndpoint('http://test-api.com/', 'dummy', 'dummy')))
     self.assertEqual(6, len(list(Product.by_domain(TEST_DOMAIN))))
     self.assertEqual(5, len(list(Location.by_domain(TEST_DOMAIN))))
     self.assertEqual(6, len(list(CommCareUser.by_domain(TEST_DOMAIN))))
     self.assertEqual(5, len(list(WebUser.by_domain(TEST_DOMAIN))))
     self.assertEqual(ILSMigrationStats.objects.filter(domain=TEST_DOMAIN).count(), 1)
Exemplo n.º 2
0
    def test_balance(self):
        endpoint = MockEndpoint('http://test-api.com/', 'dummy', 'dummy')
        bootstrap_domain(ILSGatewayAPI(TEST_DOMAIN, endpoint))
        self.assertEqual(ILSMigrationStats.objects.filter(domain=TEST_DOMAIN).count(), 1)
        self.assertEqual(ILSMigrationProblem.objects.count(), 0)

        web_user = WebUser.get_by_username('*****@*****.**')
        web_user.get_domain_membership(TEST_DOMAIN).location_id = None
        web_user.save()

        sms_user = CommCareUser.by_domain(TEST_DOMAIN)[0]
        sms_user.phone_numbers = []
        sms_user.save()

        balance_migration_task(TEST_DOMAIN, endpoint)
        self.assertEqual(ILSMigrationProblem.objects.count(), 2)

        bootstrap_domain(ILSGatewayAPI(TEST_DOMAIN, endpoint))
        self.assertEqual(ILSMigrationProblem.objects.count(), 0)
Exemplo n.º 3
0
def ils_bootstrap_domain_test_task(domain, endpoint):
    from custom.logistics.commtrack import bootstrap_domain
    from custom.ilsgateway.api import ILSGatewayAPI
    return bootstrap_domain(ILSGatewayAPI(domain, endpoint))
Exemplo n.º 4
0
def ews_bootstrap_domain_task(domain):
    ews_config = EWSGhanaConfig.for_domain(domain)
    return bootstrap_domain(EWSApi(domain, GhanaEndpoint.from_config(ews_config)))
Exemplo n.º 5
0
def ils_bootstrap_domain_test_task(domain, endpoint):
    from custom.logistics.commtrack import bootstrap_domain
    from custom.ilsgateway.api import ILSGatewayAPI
    return bootstrap_domain(ILSGatewayAPI(domain, endpoint))
Exemplo n.º 6
0
def ews_bootstrap_domain_task(domain):
    ews_config = EWSGhanaConfig.for_domain(domain)
    commtrack_settings_sync(domain, LOCATION_TYPES)
    return bootstrap_domain(ews_config, GhanaEndpoint.from_config(ews_config), EXTENSIONS, fetch_groups=False)
Exemplo n.º 7
0
def ews_bootstrap_domain_task(domain):
    ews_config = EWSGhanaConfig.for_domain(domain)
    return bootstrap_domain(
        EWSApi(domain, GhanaEndpoint.from_config(ews_config)))
Exemplo n.º 8
0
def ils_bootstrap_domain_test_task(domain, endpoint):
    ils_config = ILSGatewayConfig.for_domain(domain)
    from custom.logistics.commtrack import bootstrap_domain
    return bootstrap_domain(ils_config, endpoint)