Exemplo n.º 1
0
    def setUpClass(cls):
        super(TestZapierIntegration, cls).setUpClass()
        generator.instantiate_accounting()

        cls.domain_object = Domain.get_or_create_with_name(TEST_DOMAIN,
                                                           is_active=True)
        cls.domain = cls.domain_object.name

        account = BillingAccount.get_or_create_account_by_domain(
            cls.domain, created_by="automated-test")[0]
        plan = DefaultProductPlan.get_default_plan_version(
            edition=SoftwarePlanEdition.STANDARD)
        subscription = Subscription.new_domain_subscription(
            account, cls.domain, plan)
        subscription.is_active = True
        subscription.save()

        cls.web_user = WebUser.create(cls.domain, 'test', '******')
        api_key_object, _ = ApiKey.objects.get_or_create(
            user=cls.web_user.get_django_user())
        cls.api_key = api_key_object.key
        cls.application = Application.new_app(cls.domain, 'Test App')
        cls.application.save()
        module = cls.application.add_module(Module.new_module(
            "Module 1", "en"))
        cls.application.new_form(module.id,
                                 name="Form1",
                                 attachment=XFORM,
                                 lang="en")
        cls.application.save()
Exemplo n.º 2
0
 def setUp(self):
     super(TestCreditStripePaymentHandler, self).setUp()
     generator.instantiate_accounting()
     self.domain = Domain(name='test-domain')
     self.domain.save()
     self.payment_method = PaymentMethod()
     self.payment_method.save()
     self.account, _ = BillingAccount.get_or_create_account_by_domain(
         self.domain.name, created_by='*****@*****.**')
Exemplo n.º 3
0
    def setup_subscription(cls, domain_name, software_plan):
        generator.instantiate_accounting()

        plan = DefaultProductPlan.get_default_plan_version(edition=software_plan)
        cls.account = BillingAccount.get_or_create_account_by_domain(
            domain_name, created_by="automated-test" + cls.__name__
        )[0]
        cls.subscription = Subscription.new_domain_subscription(cls.account, domain_name, plan)
        cls.subscription.is_active = True
        cls.subscription.save()
Exemplo n.º 4
0
    def setup_subscription(cls, domain_name, software_plan):
        generator.instantiate_accounting()

        plan = DefaultProductPlan.get_default_plan_version(edition=software_plan)
        cls.account = BillingAccount.get_or_create_account_by_domain(
            domain_name, created_by="automated-test" + cls.__name__
        )[0]
        cls.subscription = Subscription.new_domain_subscription(cls.account, domain_name, plan)
        cls.subscription.is_active = True
        cls.subscription.save()
Exemplo n.º 5
0
    def setUpClass(cls):
        super(RegistrationAPITestCase, cls).setUpClass()
        Role.get_cache().clear()
        generator.instantiate_accounting()

        cls.domain1, cls.account1, cls.subscription1 = cls.setup_domain('reg-api-test-1')
        cls.domain2, cls.account2, cls.subscription2 = cls.setup_domain('reg-api-test-2')

        cls.admin_user1 = cls.setup_webuser('admin@reg-api-test-1', cls.domain1, 'admin')
        cls.read_only_user1 = cls.setup_webuser('readonly@reg-api-test-1', cls.domain1, 'read-only')
        cls.admin_user2 = cls.setup_webuser('admin@reg-api-test-2', cls.domain2, 'admin')
Exemplo n.º 6
0
    def setUpClass(cls):
        super(RegistrationAPITestCase, cls).setUpClass()
        Role.get_cache().clear()
        generator.instantiate_accounting()

        cls.domain1, cls.account1, cls.subscription1 = cls.setup_domain('reg-api-test-1')
        cls.domain2, cls.account2, cls.subscription2 = cls.setup_domain('reg-api-test-2')

        cls.admin_user1 = cls.setup_webuser('admin@reg-api-test-1', cls.domain1, 'admin')
        cls.read_only_user1 = cls.setup_webuser('readonly@reg-api-test-1', cls.domain1, 'read-only')
        cls.admin_user2 = cls.setup_webuser('admin@reg-api-test-2', cls.domain2, 'admin')
Exemplo n.º 7
0
def prepare_domain(domain_name):
    from corehq.apps.commtrack.tests.util import bootstrap_domain
    domain = bootstrap_domain(domain_name)
    previous = None
    for name, administrative in [
        ("MOHSW", True),
        ("MSDZONE", True),
        ("REGION", True),
        ("DISTRICT", True),
        ("FACILITY", False)
    ]:
        previous, _ = LocationType.objects.get_or_create(
            domain=domain_name,
            name=name,
            parent_type=previous,
            administrative=administrative,
        )

    generator.instantiate_accounting()
    account = BillingAccount.get_or_create_account_by_domain(
        domain.name,
        created_by="automated-test",
    )[0]
    plan = DefaultProductPlan.get_default_plan(
        edition=SoftwarePlanEdition.ADVANCED
    )
    commtrack = domain.commtrack_settings
    commtrack.actions.append(
        CommtrackActionConfig(action='receipts',
                              keyword='delivered',
                              caption='Delivered')
    )
    commtrack.save()
    subscription = Subscription.new_domain_subscription(
        account,
        domain.name,
        plan
    )
    subscription.is_active = True
    subscription.save()
    ils_config = ILSGatewayConfig(enabled=True, domain=domain.name, all_stock_data=True)
    ils_config.save()
    fields_definition = CustomDataFieldsDefinition.get_or_create(domain.name, 'LocationFields')
    fields_definition.fields.append(CustomDataField(
        slug='group',
        label='Group',
        is_required=False,
        choices=['A', 'B', 'C'],
        is_multiple_choice=False
    ))
    fields_definition.save()
    return domain
Exemplo n.º 8
0
def prepare_domain(domain_name):
    from corehq.apps.commtrack.tests.util import bootstrap_domain
    domain = bootstrap_domain(domain_name)
    previous = None
    for name, administrative in [
        ("MOHSW", True),
        ("MSDZONE", True),
        ("REGION", True),
        ("DISTRICT", True),
        ("FACILITY", False)
    ]:
        previous, _ = LocationType.objects.get_or_create(
            domain=domain_name,
            name=name,
            parent_type=previous,
            administrative=administrative,
        )

    generator.instantiate_accounting()
    account = BillingAccount.get_or_create_account_by_domain(
        domain.name,
        created_by="automated-test",
    )[0]
    plan = DefaultProductPlan.get_default_plan_version(
        edition=SoftwarePlanEdition.ADVANCED
    )
    commtrack = domain.commtrack_settings
    commtrack.actions.append(
        CommtrackActionConfig(action='receipts',
                              keyword='delivered',
                              caption='Delivered')
    )
    commtrack.save()
    subscription = Subscription.new_domain_subscription(
        account,
        domain.name,
        plan
    )
    subscription.is_active = True
    subscription.save()
    ils_config = ILSGatewayConfig(enabled=True, domain=domain.name, all_stock_data=True)
    ils_config.save()
    fields_definition = CustomDataFieldsDefinition.get_or_create(domain.name, 'LocationFields')
    fields_definition.fields.append(CustomDataField(
        slug='group',
        label='Group',
        is_required=False,
        choices=['A', 'B', 'C'],
        is_multiple_choice=False
    ))
    fields_definition.save()
    return domain
Exemplo n.º 9
0
def prepare_domain(domain_name):
    domain = create_domain(domain_name)
    domain.convert_to_commtrack()
    domain.save()
    set_domain_default_backend_to_test_backend(domain.name)

    def _make_loc_type(name, administrative=False, parent_type=None):
        return LocationType.objects.get_or_create(
            domain=domain_name,
            name=name,
            administrative=administrative,
            parent_type=parent_type,
        )[0]

    country = _make_loc_type(name="country", administrative=True)
    _make_loc_type(name="Central Medical Store", parent_type=country)
    _make_loc_type(name="Teaching Hospital", parent_type=country)

    region = _make_loc_type(name="region",
                            administrative=True,
                            parent_type=country)
    _make_loc_type(name="Regional Medical Store", parent_type=region)
    _make_loc_type(name="Regional Hospital", parent_type=region)

    district = _make_loc_type(name="district",
                              administrative=True,
                              parent_type=region)
    _make_loc_type(name="Clinic", parent_type=district)
    _make_loc_type(name="District Hospital", parent_type=district)
    _make_loc_type(name="Health Centre", parent_type=district)
    _make_loc_type(name="CHPS Facility", parent_type=district)
    _make_loc_type(name="Hospital", parent_type=district)
    _make_loc_type(name="Psychiatric Hospital", parent_type=district)
    _make_loc_type(name="Polyclinic", parent_type=district)
    _make_loc_type(name="facility", parent_type=district)

    generator.instantiate_accounting()
    account = BillingAccount.get_or_create_account_by_domain(
        domain.name,
        created_by="automated-test",
    )[0]
    plan = DefaultProductPlan.get_default_plan(
        edition=SoftwarePlanEdition.ADVANCED)
    subscription = Subscription.new_domain_subscription(
        account, domain.name, plan)
    subscription.is_active = True
    subscription.save()
    ews_config = EWSGhanaConfig(enabled=True, domain=domain.name)
    ews_config.save()
    return domain
Exemplo n.º 10
0
def prepare_domain(domain_name):
    domain = create_domain(domain_name)
    domain.convert_to_commtrack()
    domain.save()
    set_domain_default_backend_to_test_backend(domain.name)

    def _make_loc_type(name, administrative=False, parent_type=None):
        return LocationType.objects.get_or_create(
            domain=domain_name,
            name=name,
            administrative=administrative,
            parent_type=parent_type,
        )[0]

    country = _make_loc_type(name="country", administrative=True)
    _make_loc_type(name="Central Medical Store", parent_type=country)
    _make_loc_type(name="Teaching Hospital", parent_type=country)

    region = _make_loc_type(name="region", administrative=True, parent_type=country)
    _make_loc_type(name="Regional Medical Store", parent_type=region)
    _make_loc_type(name="Regional Hospital", parent_type=region)

    district = _make_loc_type(name="district", administrative=True, parent_type=region)
    _make_loc_type(name="Clinic", parent_type=district)
    _make_loc_type(name="District Hospital", parent_type=district)
    _make_loc_type(name="Health Centre", parent_type=district)
    _make_loc_type(name="CHPS Facility", parent_type=district)
    _make_loc_type(name="Hospital", parent_type=district)
    _make_loc_type(name="Psychiatric Hospital", parent_type=district)
    _make_loc_type(name="Polyclinic", parent_type=district)
    _make_loc_type(name="facility", parent_type=district)

    generator.instantiate_accounting()
    account = BillingAccount.get_or_create_account_by_domain(
        domain.name,
        created_by="automated-test",
    )[0]
    plan = DefaultProductPlan.get_default_plan_version(
        edition=SoftwarePlanEdition.ADVANCED
    )
    subscription = Subscription.new_domain_subscription(
        account,
        domain.name,
        plan
    )
    subscription.is_active = True
    subscription.save()
    ews_config = EWSGhanaConfig(enabled=True, domain=domain.name)
    ews_config.save()
    return domain
    def setUpClass(cls):
        generator.instantiate_accounting()

        cls.base_domain = Domain(name="base", is_active=True)
        cls.base_domain.save()
        cls.user = WebUser.create(cls.base_domain.name, "tarso", "*****")
        cls.user.save()

        cls._to_delete = []
        cls.community = Domain(name="community", is_active=True)
        cls.community.save()
        cls._setup_subscription(cls.community.name, SoftwarePlanEdition.COMMUNITY)

        cls.enterprise = Domain(name="enterprise", is_active=True)
        cls.enterprise.save()
        cls._setup_subscription(cls.enterprise.name, SoftwarePlanEdition.ENTERPRISE)

        for domain in [cls.community, cls.enterprise]:
            cls.user.add_domain_membership(domain.name, is_admin=True)
Exemplo n.º 12
0
    def setUpClass(cls):
        super(TestSubscriptionProperties, cls).setUpClass()
        generator.instantiate_accounting()

        cls.base_domain = Domain(name="base", is_active=True)
        cls.base_domain.save()
        cls.user = WebUser.create(cls.base_domain.name, "tarso", "*****")
        cls.user.save()

        cls.community = Domain(name="community", is_active=True)
        cls.community.save()
        cls._setup_subscription(cls.community.name,
                                SoftwarePlanEdition.COMMUNITY)

        cls.enterprise = Domain(name="enterprise", is_active=True)
        cls.enterprise.save()
        cls._setup_subscription(cls.enterprise.name,
                                SoftwarePlanEdition.ENTERPRISE)

        for domain in [cls.community, cls.enterprise]:
            cls.user.add_domain_membership(domain.name, is_admin=True)
Exemplo n.º 13
0
 def setUpClass(cls):
     super(TestZapierCreateCaseAction, cls).setUpClass()
     generator.instantiate_accounting()
     cls.domain_object = Domain.get_or_create_with_name('fruit',
                                                        is_active=True)
     cls.domain = cls.domain_object.name
     account = BillingAccount.get_or_create_account_by_domain(
         cls.domain, created_by="automated-test")[0]
     plan = DefaultProductPlan.get_default_plan_version(
         edition=SoftwarePlanEdition.STANDARD)
     subscription = Subscription.new_domain_subscription(
         account, cls.domain, plan)
     subscription.is_active = True
     subscription.save()
     cls.query_string = "?domain=fruit&case_type=watermelon&owner_id=test_user&user=test"
     cls.data = {'case_name': 'test1', 'price': '11'}
     cls.accessor = CaseAccessors(cls.domain)
     cls.user = WebUser.create(cls.domain, 'test', '******')
     api_key_object, _ = ApiKey.objects.get_or_create(
         user=cls.user.get_django_user())
     cls.api_key = api_key_object.key
Exemplo n.º 14
0
    def setUpClass(cls):
        super(TestZapierIntegration, cls).setUpClass()
        generator.instantiate_accounting()

        cls.domain_object = Domain.get_or_create_with_name(TEST_DOMAIN, is_active=True)
        cls.domain = cls.domain_object.name

        account = BillingAccount.get_or_create_account_by_domain(cls.domain, created_by="automated-test")[0]
        plan = DefaultProductPlan.get_default_plan_version(edition=SoftwarePlanEdition.STANDARD)
        subscription = Subscription.new_domain_subscription(account, cls.domain, plan)
        subscription.is_active = True
        subscription.save()

        cls.web_user = WebUser.create(cls.domain, 'test', '******')
        api_key_object, _ = ApiKey.objects.get_or_create(user=cls.web_user.get_django_user())
        cls.api_key = api_key_object.key
        cls.application = Application.new_app(cls.domain, 'Test App')
        cls.application.save()
        module = cls.application.add_module(Module.new_module("Module 1", "en"))
        cls.application.new_form(module.id, name="Form1", attachment=XFORM, lang="en")
        cls.application.save()
Exemplo n.º 15
0
 def setUp(self):
     super(TestExplicitCommunitySubscriptions, self).setUp()
     generator.instantiate_accounting()
     assert Subscription.objects.count() == 0
Exemplo n.º 16
0
 def setUpClass(cls):
     super(BaseAccountingTest, cls).setUpClass()
     Role.get_cache().clear()
     generator.instantiate_accounting()
Exemplo n.º 17
0
 def setUp(self):
     super(TestExplicitCommunitySubscriptions, self).setUp()
     generator.instantiate_accounting()
     assert Subscription.objects.count() == 0
Exemplo n.º 18
0
 def setUpClass(cls):
     super(BaseAccountingTest, cls).setUpClass()
     Role.get_cache().clear()
     generator.instantiate_accounting()
Exemplo n.º 19
0
 def setUpClass(cls):
     super(TestDeleteDomain, cls).setUpClass()
     generator.instantiate_accounting()