Example #1
0
    def setUp(self):
        delete_all_xforms()
        delete_all_cases()

        post_case_blocks([
            CaseBlock(
                create=True,
                case_id='mother_case_id',
                case_type='mother-case',
            ).as_xml()
        ], {'domain': TEST_DOMAIN})

        self.case_id = 'test_case_1'
        self.date_modified = datetime.utcnow() - timedelta(hours=1)
        self.date_modified = self.date_modified.replace(microsecond=0)
        post_case_blocks([
            CaseBlock(
                create=True,
                case_id=self.case_id,
                owner_id="owner",
                user_id='user',
                case_type='c_type',
                case_name=('a' * TEST_NAME_LEN) + '123456789',
                external_id='external_id',
                date_modified=self.date_modified,
                update={'foo': 'bar'},
                index={'mom': ('mother-case', 'mother_case_id')}
            ).as_xml()
        ], {'domain': TEST_DOMAIN})

        instance = CommCareCase.get(self.case_id)
        self.casedata = CaseData.create_or_update_from_instance(instance)
Example #2
0
    def setUp(self):
        delete_all_xforms()
        delete_all_cases()

        FormProcessorInterface.post_case_blocks(
            [CaseBlock(create=True, case_id="mother_case_id", case_type="mother-case").as_xml()],
            {"domain": TEST_DOMAIN},
        )

        self.case_id = "test_case_1"
        self.date_modified = datetime.utcnow() - timedelta(hours=1)
        self.date_modified = self.date_modified.replace(microsecond=0)
        FormProcessorInterface.post_case_blocks(
            [
                CaseBlock(
                    create=True,
                    case_id=self.case_id,
                    owner_id="owner",
                    user_id="user",
                    case_type="c_type",
                    case_name=("a" * TEST_NAME_LEN) + "123456789",
                    external_id="external_id",
                    date_modified=self.date_modified,
                    update={"foo": "bar"},
                    index={"mom": ("mother-case", "mother_case_id")},
                ).as_xml()
            ],
            {"domain": TEST_DOMAIN},
        )

        instance = CommCareCase.get(self.case_id)
        self.casedata = CaseData.create_or_update_from_instance(instance)
Example #3
0
 def tearDown(self):
     for user in self.users:
         django_user = user.get_django_user()
         django_user.delete()
         user.delete()
     delete_all_cases()
     clear_toggle_cache(toggles.CLOUDCARE_CACHE.slug, TEST_DOMAIN, toggles.NAMESPACE_DOMAIN)
Example #4
0
 def tearDown(self):
     for user in self.users:
         django_user = user.get_django_user()
         django_user.delete()
         user.delete()
     delete_all_cases()
     clear_toggle_cache(toggles.CLOUDCARE_CACHE.slug, TEST_DOMAIN, toggles.NAMESPACE_DOMAIN)
Example #5
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain()
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config()
            self.ct_settings.save()

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.users = [bootstrap_user(self, **user_def) for user_def in self.user_definitions]

        if False:
            # bootstrap additional users for requisitions
            # needs to get reinserted for requisition stuff later
            self.approver = bootstrap_user(self, **APPROVER_USER)
            self.packer = bootstrap_user(self, **PACKER_USER)
            self.users += [self.approver, self.packer]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()
        self.sp.owner_id = self.group._id
        self.sp.save()
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Example #6
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain(requisitions_enabled=self.requisitions_enabled)
        self.loc = make_loc('loc1')

        self.reporters = dict((k, bootstrap_user(self, **v)) for k, v in REPORTING_USERS.iteritems())
        # backwards compatibility
        self.user = self.reporters['roaming']

        # bootstrap additional users for requisitions
        self.approver = bootstrap_user(self, **APPROVER_USER)
        self.packer = bootstrap_user(self, **PACKER_USER)

        self.users = self.reporters.values() + [self.approver, self.packer]
        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()

        self.sp = make_supply_point(self.domain.name, self.loc, owner_id=self.group._id)
        self.products = Product.by_domain(self.domain.name)
        self.assertEqual(3, len(self.products))
        self.spps = {}
        for p in self.products:
            self.spps[p.code] = make_supply_point_product(self.sp, p._id)
            self.assertEqual(self.spps[p.code].owner_id, self.group._id)
Example #7
0
    def setUp(self):
        delete_all_xforms()
        delete_all_cases()

        post_case_blocks([
            CaseBlock(
                create=True,
                case_id='mother_case_id',
                case_type='mother-case',
                version=V2,
            ).as_xml()
        ], {'domain': TEST_DOMAIN})

        self.case_id = 'test_case_1'
        self.date_modified = datetime.utcnow() - timedelta(hours=1)
        self.date_modified = self.date_modified.replace(microsecond=0)
        post_case_blocks([
            CaseBlock(
                create=True,
                case_id=self.case_id,
                owner_id="owner",
                user_id='user',
                case_type='c_type',
                case_name=('a' * TEST_NAME_LEN) + '123456789',
                external_id='external_id',
                date_modified=self.date_modified,
                version=V2,
                update={'foo': 'bar'},
                index={'mom': ('mother-case', 'mother_case_id')}
            ).as_xml()
        ], {'domain': TEST_DOMAIN})

        instance = CommCareCase.get(self.case_id)
        self.casedata = CaseData.create_or_update_from_instance(instance)
Example #8
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain(requisitions_enabled=self.requisitions_enabled)
        self.user = bootstrap_user(**MAIN_USER)
        self.verified_number = self.user.get_verified_number()

        # bootstrap additional users for requisitions
        self.approver = bootstrap_user(**APPROVER_USER)
        self.packer = bootstrap_user(**PACKER_USER)

        self.users = [self.user, self.approver, self.packer]
        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc, owner_id=self.group._id)
        self.products = Product.by_domain(self.domain.name)
        self.assertEqual(3, len(self.products))
        self.spps = {}
        for p in self.products:
            self.spps[p.code] = make_supply_point_product(self.sp, p._id)
            self.assertEqual(self.spps[p.code].owner_id, self.group._id)
 def setUp(self):
     self.datapath = os.path.join(os.path.dirname(__file__), 'data')
     self.api = MockOpenLMISEndpoint("uri://mock/lmis/endpoint", username='******', password='******')
     bootstrap_domain(TEST_DOMAIN)
     delete_all_cases()
     for product in Product.by_domain(TEST_DOMAIN):
         product.delete()
Example #10
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain(requisitions_enabled=self.requisitions_enabled)
        self.loc = make_loc('loc1')

        self.reporters = dict((k, bootstrap_user(self, **v)) for k, v in REPORTING_USERS.iteritems())
        # backwards compatibility
        self.user = self.reporters['roaming']

        # bootstrap additional users for requisitions
        self.approver = bootstrap_user(self, **APPROVER_USER)
        self.packer = bootstrap_user(self, **PACKER_USER)

        self.users = self.reporters.values() + [self.approver, self.packer]
        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()

        self.sp = make_supply_point(self.domain.name, self.loc, owner_id=self.group._id)
        self.products = Product.by_domain(self.domain.name)
        self.assertEqual(3, len(self.products))
        self.spps = {}
        for p in self.products:
            self.spps[p.code] = make_supply_point_product(self.sp, p._id)
            self.assertEqual(self.spps[p.code].owner_id, self.group._id)
 def setUp(self):
     self.domain = Domain.get_or_create_with_name(TEST_DOMAIN_NAME, is_active=True)
     self.user = WebUser.create(TEST_DOMAIN_NAME, TEST_USER, TEST_PASSWORD)
     self.user.set_role(self.domain.name, 'admin')
     self.user.save()
     delete_all_cases()
     delete_all_xforms()
     time.sleep(1)
Example #12
0
    def setUp(self):
        self.domain = create_domain("importer-test").name
        self.default_case_type = 'importer-test-casetype'
        self.default_headers = ['case_id', 'age', 'sex', 'location']

        self.couch_user = WebUser.create(None, "test", "foobar")
        self.couch_user.add_domain_membership(self.domain, is_admin=True)
        self.couch_user.save()
        delete_all_cases()
Example #13
0
 def setUp(self):
     self.domain = Domain.get_or_create_with_name(TEST_DOMAIN_NAME,
                                                  is_active=True)
     self.user = WebUser.create(TEST_DOMAIN_NAME, TEST_USER, TEST_PASSWORD)
     self.user.set_role(self.domain.name, 'admin')
     self.user.save()
     delete_all_cases()
     delete_all_xforms()
     time.sleep(1)
Example #14
0
    def setUp(self):
        self.domain = create_domain("importer-test").name
        self.default_case_type = 'importer-test-casetype'
        self.default_headers = ['case_id', 'age', 'sex', 'location']

        self.couch_user = WebUser.create(None, "test", "foobar")
        self.couch_user.add_domain_membership(self.domain, is_admin=True)
        self.couch_user.save()
        delete_all_cases()
Example #15
0
 def setUp(self):
     self.datapath = os.path.join(os.path.dirname(__file__), 'data')
     bootstrap_domain(TEST_DOMAIN)
     delete_all_cases()
     for loc in Location.by_domain(TEST_DOMAIN):
         loc.delete()
     LocationType.objects.get_or_create(
         domain=TEST_DOMAIN,
         name="Lvl3 Hospital",
     )
 def setUp(self):
     self.datapath = os.path.join(os.path.dirname(__file__), 'data')
     bootstrap_domain(TEST_DOMAIN)
     delete_all_cases()
     for loc in Location.by_domain(TEST_DOMAIN):
         loc.delete()
     LocationType.objects.get_or_create(
         domain=TEST_DOMAIN,
         name="Lvl3 Hospital",
     )
 def setUp(self):
     self.datapath = os.path.join(os.path.dirname(__file__), 'data')
     self.api = MockOpenLMISEndpoint("uri://mock/lmis/endpoint",
                                     username='******',
                                     password='******')
     initial_bootstrap(TEST_DOMAIN)
     bootstrap_domain(TEST_DOMAIN)
     delete_all_cases()
     for product in Product.by_domain(TEST_DOMAIN):
         product.delete()
Example #18
0
    def setUp(self):
        delete_all_xforms()
        delete_all_cases()

        self.domain = create_domain(UTH_DOMAIN)

        username = format_username('vscan_user', UTH_DOMAIN)

        self.vscan_user = CommCareUser.get_by_username(
            username) or CommCareUser.create(UTH_DOMAIN, username, 'secret')

        self.case_id = self.create_scan_case(self.vscan_user._id, 'VH014466XK',
                                             '123123', '2014-03-28T10:48:49Z')
Example #19
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain()
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config(
            )

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.users = [
            bootstrap_user(self, **user_def)
            for user_def in self.user_definitions
        ]

        if False:
            # bootstrap additional users for requisitions
            # needs to get reinserted for requisition stuff later
            self.approver = bootstrap_user(self, **APPROVER_USER)
            self.packer = bootstrap_user(self, **PACKER_USER)
            self.users += [self.approver, self.packer]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN,
                           name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()
        self.sp.owner_id = self.group._id
        self.sp.save()
        self.products = sorted(Product.by_domain(self.domain.name),
                               key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Example #20
0
    def setUp(self):
        delete_all_xforms()
        delete_all_cases()

        self.domain = create_domain(UTH_DOMAIN)

        username = format_username('vscan_user', UTH_DOMAIN)

        self.vscan_user = CommCareUser.get_by_username(username) or CommCareUser.create(
            UTH_DOMAIN,
            username,
            'secret'
        )

        self.case_id = self.create_scan_case(
            self.vscan_user._id,
            'VH014466XK',
            '123123',
            '2014-03-28T10:48:49Z'
        )
Example #21
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        delete_all_sync_logs()

        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain()
        bootstrap_location_types(self.domain.name)
        bootstrap_products(self.domain.name)
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config()

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.users = [bootstrap_user(self, **user_def) for user_def in self.user_definitions]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()
        self.sp.owner_id = self.group._id
        self.sp.save()
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Example #22
0
 def setUp(self):
     self.datapath = os.path.join(os.path.dirname(__file__), 'data')
     bootstrap_domain(TEST_DOMAIN)
     delete_all_cases()
     for loc in Location.by_domain(TEST_DOMAIN):
         loc.delete()
Example #23
0
 def setUp(self):
     settings.CASEXML_FORCE_DOMAIN_CHECK = False
     delete_all_xforms()
     delete_all_cases()
 def setUp(cls):
     delete_all_cases()
Example #25
0
 def setUp(self):
     delete_all_cases()
     self.assertTrue(ENABLE_LOADTEST_USERS.enabled('foo'))
Example #26
0
 def setUpClass(cls):
     delete_all_cases()
Example #27
0
 def setUp(self):
     delete_all_cases()
Example #28
0
 def setUp(self):
     self.domain = 'gigglyfoo'
     delete_all_xforms()
     delete_all_cases()
 def testCountNonZero(self):
     CommCareCase().save()
     CommCareCase().save()
     self.assertEqual(2, get_total_case_count())
     delete_all_cases()
Example #30
0
 def testCountNonZero(self):
     CommCareCase().save()
     CommCareCase().save()
     self.assertEqual(2, get_total_case_count())
     delete_all_cases()
 def setUpClass(cls):
     delete_all_cases()
Example #32
0
 def setUpClass(cls):
     delete_all_cases()
     cls.domain = Domain(name='foo')
     cls.domain.save()
     cls.user = CommCareUser.create(cls.domain.name, 'somebody', 'password')
     cls.user_id = cls.user._id
 def setUp(self):
     delete_all_xforms()
     delete_all_cases()
 def setUp(self):
     delete_all_cases()
     self.assertTrue(ENABLE_LOADTEST_USERS.enabled('foo'))
 def setUp(self):
     delete_all_cases()
 def setUp(self):
     self.domain = 'gigglyfoo'
     delete_all_xforms()
     delete_all_cases()
 def setUp(self):
     delete_all_cases()
     self.domain = Domain(name='foo')
     self.domain.save()
     self.user = CommCareUser.create(self.domain.name, 'somebody', 'password')
     self.user_id = self.user._id
 def tearDown(self):
     delete_all_xforms()
     delete_all_cases()
     self.domain_object.delete()
     TimezoneMigrationProgress.objects.all().delete()
 def setUp(self):
     self.datapath = os.path.join(os.path.dirname(__file__), 'data')
     bootstrap_domain(TEST_DOMAIN)
     delete_all_cases()
     for loc in Location.by_domain(TEST_DOMAIN):
         loc.delete()
 def setUpClass(cls):
     delete_all_cases()
     cls.domain = Domain(name='foo')
     cls.domain.save()
     cls.user = CommCareUser.create(cls.domain.name, 'somebody', 'password')
     cls.user_id = cls.user._id
 def setUp(self):
     delete_all_xforms()
     delete_all_cases()
Example #42
0
 def setUp(cls):
     delete_all_cases()
Example #43
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain()
        self.domain.location_types = [
            LocationType(
                name='state',
                allowed_parents=[''],
                administrative=True
            ),
            LocationType(
                name='district',
                allowed_parents=['state'],
                administrative=True
            ),
            LocationType(
                name='block',
                allowed_parents=['district'],
                administrative=True
            ),
            LocationType(
                name='village',
                allowed_parents=['block'],
                administrative=True
            ),
            LocationType(
                name='outlet',
                allowed_parents=['village']
            ),
        ]
        self.domain.save()
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config()

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.users = [bootstrap_user(self, **user_def) for user_def in self.user_definitions]

        if False:
            # bootstrap additional users for requisitions
            # needs to get reinserted for requisition stuff later
            self.approver = bootstrap_user(self, **APPROVER_USER)
            self.packer = bootstrap_user(self, **PACKER_USER)
            self.users += [self.approver, self.packer]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()
        self.sp.owner_id = self.group._id
        self.sp.save()
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
 def tearDown(self):
     delete_all_cases()
 def setUp(self):
     self.domain = "gigglyfoo"
     self.interface = FormProcessorInterface()
     delete_all_xforms()
     delete_all_cases()