Esempio n. 1
0
 def setUpClass(cls):
     super(HandlerTest, cls).setUpClass()
     cls.domain = 'ews-handler-test'
     bootstrap_domain(cls.domain)
     cls.create_account_and_subscription(cls.domain)
     cls.domain_obj = Domain.get_by_name(cls.domain)
     cls.loc = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=cls.domain)
     cls.user = bootstrap_user(username='******', phone_number='323232', domain=cls.domain,
                                home_loc=cls.loc)
Esempio n. 2
0
 def setUp(self):
     super(HandlerTest, self).setUp()
     self.backend, self.backend_mapping = setup_default_sms_test_backend()
     self.domain = 'ews-handler-test'
     bootstrap_domain(self.domain)
     self.create_account_and_subscription(self.domain)
     self.domain_obj = Domain.get_by_name(self.domain)
     self.loc = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=self.domain)
     self.user = bootstrap_user(username='******', phone_number='323232', domain=self.domain,
         home_loc=self.loc)
Esempio n. 3
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",
     )
Esempio n. 4
0
 def setUpClass(cls):
     super(HandlerTest, cls).setUpClass()
     cls.domain = 'ews-handler-test'
     bootstrap_domain(cls.domain)
     cls.create_account_and_subscription(cls.domain)
     cls.domain_obj = Domain.get_by_name(cls.domain)
     cls.loc = make_loc(code="garms",
                        name="Test RMS",
                        type="Regional Medical Store",
                        domain=cls.domain)
     cls.user = bootstrap_user(username='******',
                               phone_number='323232',
                               domain=cls.domain,
                               home_loc=cls.loc)
Esempio n. 5
0
 def setUp(self):
     super(HandlerTest, self).setUp()
     self.backend, self.backend_mapping = setup_default_sms_test_backend()
     self.domain = 'ews-handler-test'
     bootstrap_domain(self.domain)
     self.create_account_and_subscription(self.domain)
     self.domain_obj = Domain.get_by_name(self.domain)
     self.loc = make_loc(code="garms",
                         name="Test RMS",
                         type="Regional Medical Store",
                         domain=self.domain)
     self.user = bootstrap_user(username='******',
                                phone_number='323232',
                                domain=self.domain,
                                home_loc=self.loc)
Esempio n. 6
0
 def setUp(self):
     self.domain_obj = bootstrap_domain(self.domain)
     self.user = create_restore_user(self.domain, 'user', '123')
     self.location_types = setup_location_types_with_structure(
         self.domain, self.location_type_structure)
     self.locations = setup_locations_with_structure(
         self.domain, self.location_structure)
Esempio n. 7
0
    def setUp(self):
        super(XMLTest, self).setUp()
        self.domain = util.bootstrap_domain(util.TEST_DOMAIN)
        util.bootstrap_location_types(self.domain.name)
        util.bootstrap_products(self.domain.name)
        self.products = sorted(Product.by_domain(self.domain.name),
                               key=lambda p: p._id)
        self.ct_settings = SQLCommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.sqlconsumptionconfig = SQLConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
        )
        self.ct_settings.save()
        self.ct_settings.sqlconsumptionconfig.commtrack_settings = self.ct_settings
        self.ct_settings.sqlconsumptionconfig.save()
        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = self.loc.linked_supply_point()
        self.users = [
            util.bootstrap_user(self, **user_def)
            for user_def in self.user_definitions
        ]
        self.user = self.users[0]
Esempio n. 8
0
    def testOTASettings(self):
        domain = bootstrap_domain()
        ct_settings = CommtrackConfig.for_domain(domain.name)
        ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=10,
            min_window=20,
            optimal_window=60,
        )
        ct_settings.ota_restore_config = StockRestoreConfig(
            section_to_consumption_types={'stock': 'consumption'},
        )
        set_default_monthly_consumption_for_domain(domain.name, 5 * DAYS_IN_MONTH)
        restore_settings = ct_settings.get_ota_restore_settings()
        self.assertEqual(1, len(restore_settings.section_to_consumption_types))
        self.assertEqual('consumption', restore_settings.section_to_consumption_types['stock'])
        self.assertEqual(10, restore_settings.consumption_config.min_periods)
        self.assertEqual(20, restore_settings.consumption_config.min_window)
        self.assertEqual(60, restore_settings.consumption_config.max_window)
        self.assertEqual(150, restore_settings.consumption_config.default_monthly_consumption_function('foo', 'bar'))
        self.assertFalse(restore_settings.force_consumption_case_filter(CommCareCase(type='force-type')))
        self.assertEqual(0, len(restore_settings.default_product_list))

        ct_settings.ota_restore_config.force_consumption_case_types=['force-type']
        ct_settings.ota_restore_config.use_dynamic_product_list=True
        restore_settings = ct_settings.get_ota_restore_settings()
        self.assertTrue(restore_settings.force_consumption_case_filter(CommCareCase(type='force-type')))
        self.assertEqual(3, len(restore_settings.default_product_list))
    def test_location_restricted_cases(self):
        domain_obj = bootstrap_domain(self.domain)
        self.addCleanup(domain_obj.delete)

        location_type_names = ['state', 'county', 'city']
        location_structure = [('Massachusetts', [('Middlesex', [
            ('Cambridge', []),
            ('Somerville', []),
        ]), ('Suffolk', [
            ('Boston', []),
        ])])]
        locations = setup_locations_and_types(self.domain, location_type_names,
                                              [], location_structure)[1]
        middlesex_user = CommCareUser.create(self.domain, 'guy-from-middlesex',
                                             '***', None, None)

        middlesex_user.add_to_assigned_locations(locations['Middlesex'])
        restrict_user_by_location(self.domain, middlesex_user)

        fake_request = MagicMock()
        fake_request.domain = self.domain
        fake_request.couch_user = middlesex_user

        self._send_case_to_es(owner_id=locations['Boston'].get_id)
        middlesex_case = self._send_case_to_es(
            owner_id=locations['Middlesex'].get_id)
        cambridge_case = self._send_case_to_es(
            owner_id=locations['Cambridge'].get_id)

        returned_case_ids = query_location_restricted_cases(
            CaseES().domain(self.domain), fake_request).get_ids()
        self.assertItemsEqual(returned_case_ids,
                              [middlesex_case.case_id, cambridge_case.case_id])
Esempio n. 10
0
 def setUpClass(cls):
     cls.domain_obj = bootstrap_domain(cls.domain)
     cls.location_types, cls.locations = setup_locations_and_types(
         cls.domain,
         cls.location_type_names,
         cls.stock_tracking_types,
         cls.location_structure,
     )
Esempio n. 11
0
 def setUp(self):
     self.domain_obj = bootstrap_domain(self.domain)
     self.location_types, self.locations = setup_locations_and_types(
         self.domain,
         self.location_type_names,
         self.stock_tracking_types,
         self.location_structure,
     )
Esempio n. 12
0
 def setUp(self):
     self.domain_obj = bootstrap_domain(self.domain)
     self.location_types, self.locations = setup_locations_and_types(
         self.domain,
         self.location_type_names,
         self.stock_tracking_types,
         self.location_structure,
     )
Esempio n. 13
0
 def setUpClass(cls):
     cls.domain_obj = bootstrap_domain(cls.domain)
     cls.location_types, cls.locations = setup_locations_and_types(
         cls.domain,
         cls.location_type_names,
         cls.stock_tracking_types,
         cls.location_structure,
     )
Esempio n. 14
0
    def setUp(self):
        super(ForkedHierarchiesTest, self).setUp()
        self.domain = 'test'
        self.domain_obj = bootstrap_domain(self.domain)
        self.addCleanup(self.domain_obj.delete)

        self.user = create_restore_user(self.domain, 'user', '123')

        location_type_structure = [
            LocationTypeStructure('ctd', [
                LocationTypeStructure('sto', [
                    LocationTypeStructure('cto', [
                        LocationTypeStructure('dto', [
                            LocationTypeStructure('tu', [
                                LocationTypeStructure('phi', []),
                                LocationTypeStructure('dmc', []),
                            ]),
                        ])
                    ]),
                    LocationTypeStructure('drtb', []),
                    LocationTypeStructure('cdst', []),
                ])
            ])
        ]
        location_structure = [
            LocationStructure('CTD', 'ctd', [
                LocationStructure('STO', 'sto', [
                    LocationStructure('CTO', 'cto', [
                        LocationStructure('DTO', 'dto', [
                            LocationStructure('TU', 'tu', [
                                LocationStructure('PHI', 'phi', []),
                                LocationStructure('DMC', 'dmc', []),
                            ]),
                        ])
                    ]),
                    LocationStructure('DRTB', 'drtb', []),
                    LocationStructure('CDST', 'cdst', []),
                ]),
                LocationStructure('STO1', 'sto', [
                    LocationStructure('CTO1', 'cto', [
                        LocationStructure('DTO1', 'dto', [
                            LocationStructure('TU1', 'tu', [
                                LocationStructure('PHI1', 'phi', []),
                                LocationStructure('DMC1', 'dmc', []),
                            ]),
                        ])
                    ]),
                    LocationStructure('DRTB1', 'drtb', []),
                    LocationStructure('CDST1', 'cdst', []),
                ])
            ])
        ]

        location_metadata = {'is_test': 'no', 'nikshay_code': 'nikshay_code'}
        setup_location_types_with_structure(self.domain,
                                            location_type_structure),
        self.locations = setup_locations_with_structure(
            self.domain, location_structure, location_metadata)
Esempio n. 15
0
 def setUpClass(cls):
     super(LocationHierarchyTestCase, cls).setUpClass()
     cls.domain_obj = bootstrap_domain(cls.domain)
     cls.location_types, cls.locations = setup_locations_and_types(
         cls.domain,
         cls.location_type_names,
         cls.stock_tracking_types,
         cls.location_structure,
     )
Esempio n. 16
0
    def setUp(self):
        self.domain = 'supply-point-dbaccessors'
        self.project = bootstrap_domain(self.domain)

        self.locations = [
            make_loc('1234', name='ben', domain=self.domain),
            make_loc('1235', name='ben', domain=self.domain),
            make_loc('1236', name='ben', domain=self.domain),
        ]
Esempio n. 17
0
 def setUpClass(cls):
     super(LocationHierarchyTestCase, cls).setUpClass()
     cls.domain_obj = bootstrap_domain(cls.domain)
     cls.location_types, cls.locations = setup_locations_and_types(
         cls.domain,
         cls.location_type_names,
         cls.stock_tracking_types,
         cls.location_structure,
     )
Esempio n. 18
0
    def test_programs(self):
        self.domain = bootstrap_domain(TEST_DOMAIN)
        self.addCleanup(self.domain.delete)
        bootstrap_products(self.domain.name)
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.default_program = Program.by_domain(self.domain.name, wrap=True).one()
        self.new_program = make_program(
            self.domain.name,
            'new program',
            'newprogram'
        )
        self.assertTrue(self.default_program.default)
        self.assertFalse(self.new_program.default)

        with self.assertRaises(Exception) as context:
            self.default_program.delete()

        self.assertEqual(six.text_type(context.exception), 'You cannot delete the default program')

        # assign some product to the new program
        self.products[0].program_id = self.new_program._id
        self.products[0].save()

        # make sure start state is okay
        self.assertEqual(
            2,
            len(Program.by_domain(self.domain.name))
        )
        self.assertEqual(2, self.default_program.get_products_count())
        self.assertEqual(1, self.new_program.get_products_count())
        self.assertEqual(
            self.new_program._id,
            self.products[0].program_id
        )
        self.assertEqual(
            self.new_program._id,
            SQLProduct.objects.get(product_id=self.products[0]._id).program_id
        )

        # stash the id before we delete
        new_program_id = self.new_program._id
        self.new_program.delete()

        with self.assertRaises(ResourceNotFound):
            Program.get(new_program_id)

        self.assertEqual(1, len(Program.by_domain(self.domain.name)))
        self.assertEqual(3, self.default_program.get_products_count())
        self.assertEqual(
            self.default_program._id,
            Product.get(self.products[0]._id).program_id
        )
        self.assertEqual(
            self.default_program._id,
            SQLProduct.objects.get(product_id=self.products[0]._id).program_id
        )
    def setUp(self):
        super(ForkedHierarchiesTest, self).setUp()
        self.domain = 'test'
        self.domain_obj = bootstrap_domain(self.domain)
        self.addCleanup(self.domain_obj.delete)

        self.user = create_restore_user(self.domain, 'user', '123')

        location_type_structure = [
            LocationTypeStructure('ctd', [
                LocationTypeStructure('sto', [
                    LocationTypeStructure('cto', [
                        LocationTypeStructure('dto', [
                            LocationTypeStructure('tu', [
                                LocationTypeStructure('phi', []),
                                LocationTypeStructure('dmc', []),
                            ]),
                        ])
                    ]),
                    LocationTypeStructure('drtb', []),
                    LocationTypeStructure('cdst', []),
                ])
            ])
        ]
        location_structure = [
            LocationStructure('CTD', 'ctd', [
                LocationStructure('STO', 'sto', [
                    LocationStructure('CTO', 'cto', [
                        LocationStructure('DTO', 'dto', [
                            LocationStructure('TU', 'tu', [
                                LocationStructure('PHI', 'phi', []),
                                LocationStructure('DMC', 'dmc', []),
                            ]),
                        ])
                    ]),
                    LocationStructure('DRTB', 'drtb', []),
                    LocationStructure('CDST', 'cdst', []),
                ]),
                LocationStructure('STO1', 'sto', [
                    LocationStructure('CTO1', 'cto', [
                        LocationStructure('DTO1', 'dto', [
                            LocationStructure('TU1', 'tu', [
                                LocationStructure('PHI1', 'phi', []),
                                LocationStructure('DMC1', 'dmc', []),
                            ]),
                        ])
                    ]),
                    LocationStructure('DRTB1', 'drtb', []),
                    LocationStructure('CDST1', 'cdst', []),
                ])
            ])
        ]

        location_metadata = {'is_test': 'no', 'nikshay_code': 'nikshay_code'}
        setup_location_types_with_structure(self.domain, location_type_structure),
        self.locations = setup_locations_with_structure(self.domain, location_structure, location_metadata)
Esempio n. 20
0
 def setUp(self):
     domain = bootstrap_domain(TEST_DOMAIN)
     loc = make_loc(code="garms",
                    name="Test RMS",
                    type="Regional Medical Store",
                    domain=domain.name)
     self.user = bootstrap_user(username='******',
                                phone_number='323232',
                                domain=domain.name,
                                home_loc=loc)
Esempio n. 21
0
 def setUpClass(cls):
     super(SMSTests, cls).setUpClass()
     cls.backend, cls.backend_mapping = setup_default_sms_test_backend()
     cls.domain = util.bootstrap_domain(util.TEST_DOMAIN)
     util.bootstrap_location_types(cls.domain.name)
     util.bootstrap_products(cls.domain.name)
     cls.products = sorted(Product.by_domain(cls.domain.name), key=lambda p: p._id)
     cls.loc = util.make_loc('loc1')
     cls.sp = cls.loc.linked_supply_point()
     cls.users = [util.bootstrap_user(cls, **user_def) for user_def in cls.user_definitions]
 def setUpClass(cls):
     super(SMSTests, cls).setUpClass()
     cls.backend, cls.backend_mapping = setup_default_sms_test_backend()
     cls.domain = util.bootstrap_domain(util.TEST_DOMAIN)
     util.bootstrap_location_types(cls.domain.name)
     util.bootstrap_products(cls.domain.name)
     cls.products = sorted(Product.by_domain(cls.domain.name), key=lambda p: p._id)
     cls.loc = util.make_loc('loc1')
     cls.sp = cls.loc.linked_supply_point()
     cls.users = [util.bootstrap_user(cls, **user_def) for user_def in cls.user_definitions]
Esempio n. 23
0
    def setUp(self):
        super(SupplyPointDBAccessorsTest, self).setUp()
        self.domain = 'supply-point-dbaccessors'
        self.project = bootstrap_domain(self.domain)
        self.interface = SupplyInterface(self.domain)

        self.locations = [
            make_loc('1234', name='ben', domain=self.domain),
            make_loc('1235', name='ben', domain=self.domain),
            make_loc('1236', name='ben', domain=self.domain),
        ]
Esempio n. 24
0
    def setUp(self):
        super(SupplyPointDBAccessorsTest, self).setUp()
        self.domain = 'supply-point-dbaccessors'
        self.project = bootstrap_domain(self.domain)
        self.interface = SupplyInterface(self.domain)

        self.locations = [
            make_loc('1234', name='ben', domain=self.domain),
            make_loc('1235', name='ben', domain=self.domain),
            make_loc('1236', name='ben', domain=self.domain),
        ]
Esempio n. 25
0
 def setUp(self):
     self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
     self.domain = bootstrap_domain()
     self.user = bootstrap_user()
     self.verified_number = self.user.get_verified_number()
     self.loc = make_loc('loc1')
     self.sp = make_supply_point(self.domain.name, self.loc)
     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)
Esempio n. 26
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_for_tests()
    account = BillingAccount.get_or_create_account_by_domain(
        domain.name,
        created_by="automated-test",
    )[0]
    plan = DefaultProductPlan.get_default_plan_by_domain(
        domain, 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
Esempio n. 27
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
    def setUp(self):
        self.domain_obj = bootstrap_domain(self.domain)

        self.location_types, self.locations = setup_locations_and_types(
            self.domain,
            self.location_type_names,
            self.stock_tracking_types,
            self.location_structure,
        )

        self.suffolk = self.locations['Suffolk']
        self.boston = self.locations['Boston']
        self.county_type = self.location_types['county']
        self.city_type = self.location_types['city']
    def setUp(self):
        self.domain_obj = bootstrap_domain(self.domain)

        self.location_types, self.locations = setup_locations_and_types(
            self.domain,
            self.location_type_names,
            self.stock_tracking_types,
            self.location_structure,
        )

        self.suffolk = self.locations['Suffolk']
        self.boston = self.locations['Boston']
        self.county_type = self.location_types['county']
        self.city_type = self.location_types['city']
Esempio n. 30
0
    def setUpClass(cls):
        super(StockStatusDataSourceTests, cls).setUpClass()
        cls.domain = uuid.uuid4().hex
        cls.project = bootstrap_domain(cls.domain)
        cls.interface = SupplyInterface(cls.domain)

        cls.product = make_product(cls.domain, 'A Product', 'prodcode_a')
        cls.location = make_loc('1234', name='ben', domain=cls.domain)
        cls.location2 = make_loc('1235', name='ken', domain=cls.domain)
        cls.supply_point = cls.location.linked_supply_point()

        submit_case_blocks(
            [get_single_balance_block(cls.supply_point.case_id, cls.product._id, 50)],
            cls.domain
        )
Esempio n. 31
0
    def setUpClass(cls):
        super(StockStateTest, cls).setUpClass()
        cls.domain_obj = util.bootstrap_domain(cls.domain)
        util.bootstrap_location_types(cls.domain)
        util.bootstrap_products(cls.domain)
        cls.ct_settings = CommtrackConfig.for_domain(cls.domain)
        cls.ct_settings.use_auto_consumption = True
        cls.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        cls.ct_settings.save()

        cls.loc = util.make_loc('loc1', domain=cls.domain)
        cls.sp = cls.loc.linked_supply_point()
        cls.products = sorted(Product.by_domain(cls.domain), key=lambda p: p._id)
Esempio n. 32
0
    def setUp(self):
        super(XMLTest, self).setUp()
        self.domain = util.bootstrap_domain(util.TEST_DOMAIN)
        util.bootstrap_location_types(self.domain.name)
        util.bootstrap_products(self.domain.name)
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        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,
        )
        self.ct_settings.save()
        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = self.loc.linked_supply_point()
        self.users = [util.bootstrap_user(self, **user_def) for user_def in self.user_definitions]
        self.user = self.users[0]
Esempio n. 33
0
    def testOTASettings(self):
        domain = bootstrap_domain()
        ct_settings = CommtrackConfig.for_domain(domain.name)
        ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=10,
            min_window=20,
            optimal_window=60,
        )
        ct_settings.ota_restore_config = StockRestoreConfig(
            section_to_consumption_types={'stock': 'consumption'}, )
        set_default_monthly_consumption_for_domain(domain.name,
                                                   5 * DAYS_IN_MONTH)
        restore_settings = ct_settings.get_ota_restore_settings()
        self.assertEqual(1, len(restore_settings.section_to_consumption_types))
        self.assertEqual(
            'consumption',
            restore_settings.section_to_consumption_types['stock'])
        self.assertEqual(10, restore_settings.consumption_config.min_periods)
        self.assertEqual(20, restore_settings.consumption_config.min_window)
        self.assertEqual(60, restore_settings.consumption_config.max_window)
        self.assertEqual(
            150,
            restore_settings.consumption_config.
            default_monthly_consumption_function('foo', 'bar'))
        self.assertFalse(
            restore_settings.force_consumption_case_filter(
                CommCareCase(type='force-type')))
        self.assertEqual(0, len(restore_settings.default_product_list))

        ct_settings.ota_restore_config.force_consumption_case_types = [
            'force-type'
        ]
        ct_settings.ota_restore_config.use_dynamic_product_list = True
        restore_settings = ct_settings.get_ota_restore_settings()
        self.assertTrue(
            restore_settings.force_consumption_case_filter(
                CommCareCase(type='force-type')))
        self.assertEqual(3, len(restore_settings.default_product_list))
Esempio n. 34
0
    def setUpClass(cls):
        super(StockStateTest, cls).setUpClass()
        cls.domain_obj = util.bootstrap_domain(cls.domain)
        util.bootstrap_location_types(cls.domain)
        util.bootstrap_products(cls.domain)
        cls.ct_settings = SQLCommtrackConfig.for_domain(cls.domain)
        cls.ct_settings.use_auto_consumption = True
        cls.ct_settings.sqlconsumptionconfig = SQLConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
        )
        cls.ct_settings.save()
        cls.ct_settings.sqlconsumptionconfig.commtrack_settings = cls.ct_settings
        cls.ct_settings.sqlconsumptionconfig.save()

        cls.loc = util.make_loc('loc1', domain=cls.domain)
        cls.sp = cls.loc.linked_supply_point()
        cls.products = sorted(Product.by_domain(cls.domain),
                              key=lambda p: p._id)

        cls.process_ledger_changes = process_pillow_changes(
            'LedgerToElasticsearchPillow')
Esempio n. 35
0
 def setUp(self):
     self.domain = 'post-api-test'
     bootstrap_domain(self.domain)
     self.api = MockOpenLMISEndpoint("uri://mock/lmis/endpoint", username='******', password='******')
     self.datapath = os.path.join(os.path.dirname(__file__), 'data')
     LocationType.objects.get_or_create(domain=self.domain, name='chw')
Esempio n. 36
0
 def setUpClass(cls):
     cls.domain = 'test-domain'
     cls.domain_obj = bootstrap_domain(cls.domain)
     cls.location_types, cls.locations = setup_locations_and_types(
         cls.domain, cls.location_type_names, cls.location_structure
     )
Esempio n. 37
0
 def setUpClass(cls):
     super(FixtureTest, cls).setUpClass()
     cls.domain_obj = util.bootstrap_domain(cls.domain)
     util.bootstrap_location_types(cls.domain)
     util.bootstrap_products(cls.domain)
     cls.user = create_restore_user(cls.domain)
Esempio n. 38
0
 def setUp(self):
     self.domain = bootstrap_domain(TEST_DOMAIN)
     self.loc = make_loc('loc1')
Esempio n. 39
0
 def setUp(self):
     self.project = bootstrap_domain(self.domain)
     LocationType(domain=self.domain, name='type').save()
Esempio n. 40
0
 def setUpClass(cls):
     super(LocationsTest, cls).setUpClass()
     delete_all_users()
     cls.domain_obj = bootstrap_domain(cls.domain)
     bootstrap_location_types(cls.domain)
Esempio n. 41
0
 def setUp(self):
     super(SupplyPointTest, self).setUp()
     self.domain = bootstrap_domain(TEST_DOMAIN)
     self.loc = make_loc('loc1')
Esempio n. 42
0
 def setUpClass(cls):
     super(FixtureTest, cls).setUpClass()
     cls.domain_obj = util.bootstrap_domain(cls.domain)
     util.bootstrap_location_types(cls.domain)
     util.bootstrap_products(cls.domain)
     cls.user = create_restore_user(cls.domain)
Esempio n. 43
0
 def setUp(self):
     self.domain = bootstrap_domain()
     LocationType(domain=self.domain.name, name='type').save()
Esempio n. 44
0
 def setUp(self):
     self.domain = bootstrap_domain()
 def setUp(self):
     self.domain = bootstrap_domain(TEST_DOMAIN)
     self.loc = make_loc('loc1')
     self.sp = make_supply_point(TEST_DOMAIN, self.loc)
     self.product = make_product(TEST_DOMAIN, 'product 1', 'p1')
Esempio n. 46
0
 def setUp(self):
     self.project = bootstrap_domain(self.domain)
     self.products = SQLProduct.objects.filter(domain=self.domain)
     LocationType(domain=self.domain, name='type').save()
Esempio n. 47
0
 def setUpClass(cls):
     super(ProductsTest, cls).setUpClass()
     cls.domain_obj = bootstrap_domain(cls.domain)
Esempio n. 48
0
 def setUpClass(cls):
     super(ProductsTest, cls).setUpClass()
     cls.domain_obj = bootstrap_domain(cls.domain)
Esempio n. 49
0
 def setUp(self):
     self.domain = bootstrap_domain(TEST_DOMAIN)
     self.loc = make_loc('loc1')
Esempio n. 50
0
 def setUpClass(cls):
     super(BaseTest, cls).setUpClass()
     cls.domain_obj = bootstrap_domain(cls.domain)
 def setUp(self):
     self.domain_obj = bootstrap_domain(self.domain)
     self.user = create_restore_user(self.domain, 'user', '123')
     self.location_types = setup_location_types_with_structure(self.domain, self.location_type_structure)
     self.locations = setup_locations_with_structure(self.domain, self.location_structure)
Esempio n. 52
0
 def setUpClass(cls):
     super(TestOperation, cls).setUpClass()
     cls.domain_obj = bootstrap_domain(cls.domain)
 def setUp(self):
     self.domain = bootstrap_domain()
     self.products = SQLProduct.objects.filter(domain=self.domain)
Esempio n. 54
0
 def setUp(self):
     super(SupplyPointTest, self).setUp()
     self.domain = bootstrap_domain(TEST_DOMAIN)
     self.loc = make_loc('loc1')
Esempio n. 55
0
 def setUpClass(cls):
     super(LocationsTest, cls).setUpClass()
     delete_all_users()
     cls.domain_obj = bootstrap_domain(cls.domain)
     bootstrap_location_types(cls.domain)
Esempio n. 56
0
 def setUpClass(cls):
     super(SiteCodeTest, cls).setUpClass()
     cls.project = bootstrap_domain(cls.domain)
     LocationType(domain=cls.domain, name='type').save()
Esempio n. 57
0
 def setUp(self):
     self.domain = bootstrap_domain()
Esempio n. 58
0
 def setUp(self):
     self.domain = bootstrap_domain()
     LocationType(domain=self.domain.name, name='type').save()
 def setUp(self):
     self.domain = bootstrap_domain()
     self.products = SQLProduct.objects.filter(domain=self.domain)
     LocationType(domain=self.domain.name, name='type').save()