Пример #1
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)
Пример #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)
Пример #3
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)
Пример #4
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)
Пример #5
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)
Пример #6
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)
Пример #7
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))
Пример #8
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)
Пример #9
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)
Пример #10
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')
Пример #11
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))
Пример #12
0
    def setUpClass(cls):
        from casexml.apps.case.tests import delete_all_xforms
        delete_all_xforms()
        cls.domain = 'evelyn'
        cls.now = datetime.datetime.utcnow()
        cls.xforms = [
            XFormInstance(_id='xform_1',
                          received_on=cls.now - datetime.timedelta(days=10)),
            XFormInstance(_id='xform_2', received_on=cls.now)
        ]
        cls.xform_errors = [XFormError(_id='xform_error_1')]

        for form in cls.xforms + cls.xform_errors:
            form.domain = cls.domain
            form.save()
Пример #13
0
    def setUpClass(cls):
        from casexml.apps.case.tests import delete_all_xforms

        delete_all_xforms()
        cls.domain = "evelyn"
        cls.now = datetime.datetime.utcnow()
        cls.xforms = [
            XFormInstance(_id="xform_1", received_on=cls.now - datetime.timedelta(days=10)),
            XFormInstance(_id="xform_2", received_on=cls.now),
        ]
        cls.xform_errors = [XFormError(_id="xform_error_1")]

        for form in cls.xforms + cls.xform_errors:
            form.domain = cls.domain
            form.save()
Пример #14
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'
        )
Пример #15
0
    def setUpClass(cls):
        from casexml.apps.case.tests import delete_all_xforms
        delete_all_xforms()
        cls.now = datetime.datetime.utcnow()
        cls._60_days = datetime.timedelta(days=60)
        cls.domain = 'my_crazy_analytics_domain'
        cls.app_id = uuid.uuid4().hex
        cls.xmlns = 'my://crazy.xmlns/'
        cls.user_id = uuid.uuid4().hex
        cls.forms = [
            XFormInstance(domain=cls.domain, received_on=cls.now,
                          app_id=cls.app_id, xmlns=cls.xmlns,
                          form={'meta': {'userID': cls.user_id, 'username': '******'}}),
            XFormInstance(domain=cls.domain, received_on=cls.now - cls._60_days,
                          app_id=cls.app_id, xmlns=cls.xmlns,
                          form={'meta': {'userID': cls.user_id, 'username': '******'}}),
        ]
        for form in cls.forms:
            form.save()

        update_analytics_indexes()
Пример #16
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))
Пример #17
0
 def tearDown(self):
     delete_all_xforms()
     delete_all_cases()
     self.domain_object.delete()
     TimezoneMigrationProgress.objects.all().delete()
 def setUp(self):
     self.domain = 'gigglyfoo'
     delete_all_xforms()
     delete_all_cases()
Пример #19
0
 def setUp(self):
     settings.CASEXML_FORCE_DOMAIN_CHECK = False
     delete_all_xforms()
     delete_all_cases()
 def setUp(self):
     delete_all_xforms()
     delete_all_cases()
Пример #21
0
 def setUp(self):
     self.domain = 'gigglyfoo'
     delete_all_xforms()
     delete_all_cases()
 def setUp(self):
     delete_all_xforms()
     delete_all_cases()
Пример #23
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))
Пример #24
0
 def setUp(self):
     self.domain = "gigglyfoo"
     self.interface = FormProcessorInterface()
     delete_all_xforms()
     delete_all_cases()