def setUpClass(cls): super(TestUrgentAlerts, cls).setUpClass() cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend() cls.domain = prepare_domain(TEST_DOMAIN) cls.district = make_loc(code="district", name="Test District", type="district", domain=TEST_DOMAIN) cls.loc1 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN, parent=cls.district) cls.loc2 = make_loc(code="tf2", name="Test Facility 2", type="Hospital", domain=TEST_DOMAIN, parent=cls.district) cls.loc3 = make_loc(code="tf3", name="Test Facility 3", type="Hospital", domain=TEST_DOMAIN, parent=cls.district) cls.loc4 = make_loc(code="tf4", name="Test Facility 4", type="Hospital", domain=TEST_DOMAIN, parent=cls.district) cls.product = Product(domain=TEST_DOMAIN, name='Test Product', code_='tp', unit='each') cls.product.save() cls.product2 = Product(domain=TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each') cls.product2.save() cls.user1 = bootstrap_web_user( username='******', phone_number='1111', location=cls.district, domain=TEST_DOMAIN, first_name='test', last_name='test1', user_data={ 'role': [] }, email='*****@*****.**', password='******' ) set_sms_notifications(TEST_DOMAIN, cls.user1, True)
def test_product_decimal_value(self): products = [ Product( _id="1", domain="test-domain", name="Foo", code_="foo", cost=10, ), Product( _id="2", domain="test-domain", name="Bar", code_="bar", cost=9.99, ), Product( _id="3", domain="test-domain", name="Baz", code_="baz", cost=10.0, ), ] fixtures = simple_fixture_generator( restore_user=MockUser(user_id="123456"), id="7890ab", name="test-fixture", fields=("name", "code", "cost"), data=products, ) xml = tostring(fixtures[0]) self.assertEqual(xml, self.get_expected_xml())
def create_test_products(domain): program = Program(domain=domain, name='HIV/AIDS', code='hiv') program.save() abacavir = Product( domain=domain, name="Abacavir 300mg", code_="abc", program_id=program.get_id, ) abacavir.save() ali = Product( domain=domain, name="AL 20mg/120mg 1X6", code_="ali", program_id=program.get_id, ) ali.save() al = Product(domain=domain, name="AL 20mg/120mg 4x6", code_="alk") al.save() ad = Product(domain=domain, name="A-L Dispersible", code_="ad") ad.save() al = Product(domain=domain, name="A-L Suspension", code_="al") al.save()
def test_product_type_filter(self): """User can recieve missing notifications for only certain product type.""" bootstrap_web_user(username='******', domain=self.TEST_DOMAIN, phone_number='+44445', location=self.district, password='******', email='*****@*****.**', user_data={}, program_id=self.program.get_id) other_product = Product(domain=self.TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each') other_product2 = Product(domain=self.TEST_DOMAIN, name='Test Product3', code_='tp3', unit='each') other_product.save() other_product2.save() assign_products_to_location( self.facility, [self.product, other_product, other_product2]) generated = list( OnGoingNonReporting(self.TEST_DOMAIN).get_notifications()) self.assertEqual(len(generated), 1) self.assertEqual(generated[0].user.get_id, self.user.get_id)
def setUpClass(cls): super(IntraHealthTestCase, cls).setUpClass() cls.session_helper = connection_manager.get_session_helper( settings.SQL_REPORTING_DATABASE_URL) cls.engine = cls.session_helper.engine cls.domain = create_domain(TEST_DOMAIN) cls.region_type = LocationType.objects.create(domain=TEST_DOMAIN, name=u'Région') cls.district_type = LocationType.objects.create(domain=TEST_DOMAIN, name=u'District') cls.pps_type = LocationType.objects.create(domain=TEST_DOMAIN, name=u'PPS') cls.region = make_location(domain=TEST_DOMAIN, name='Test region', location_type=u'Région') cls.region.save() cls.district = make_location(domain=TEST_DOMAIN, name='Test district', location_type=u'District', parent=cls.region) cls.district.save() cls.pps = make_location(domain=TEST_DOMAIN, name='Test PPS', location_type=u'PPS', parent=cls.district) cls.pps.save() cls.mobile_worker = create_mobile_worker(domain=TEST_DOMAIN, username='******', password='******', phone_number='777777') cls.mobile_worker.location_id = cls.pps.get_id cls.mobile_worker.save() cls.product = Product(_id=u'81457658bdedd663f8b0bdadb19d8f22', name=u'ASAQ Nourisson', domain=TEST_DOMAIN) cls.product2 = Product(_id=u'81457658bdedd663f8b0bdadb19d83d8', name=u'ASAQ Petit Enfant', domain=TEST_DOMAIN) cls.product.save() cls.product2.save() cls.recap_table = RecapPassageFluff._table cls.intra_table = IntraHealthFluff._table cls.taux_rupt_table = TauxDeRuptureFluff._table cls.livraison_table = LivraisonFluff._table cls.taux_sat_table = TauxDeSatisfactionFluff._table cls.couverture_table = CouvertureFluff._table with cls.engine.begin() as connection: cls.recap_table.create(connection, checkfirst=True) cls.intra_table.create(connection, checkfirst=True) cls.taux_rupt_table.create(connection, checkfirst=True) cls.livraison_table.create(connection, checkfirst=True) cls.taux_sat_table.create(connection, checkfirst=True) cls.couverture_table.create(connection, checkfirst=True)
def setUpClass(cls): super(EWSTestCase, cls).setUpClass() cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend() cls.domain = prepare_domain(TEST_DOMAIN) cls.national = make_loc(code='national', name='National', type='country', domain=TEST_DOMAIN) cls.region = make_loc(code="region", name="Test Region", type="region", domain=TEST_DOMAIN, parent=cls.national) cls.rms = make_loc(code="rms", name="Test Medical Store", type="Regional Medical Store", domain=TEST_DOMAIN, parent=cls.region) cls.rms2 = make_loc(code="rms2", name="Test Medical Store 2", type="Regional Medical Store", domain=TEST_DOMAIN, parent=cls.region) cls.district = make_loc(code="district", name="Test District", type="district", domain=TEST_DOMAIN) cls.loc1 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN, parent=cls.district) cls.loc2 = make_loc(code="tf2", name="Test Facility 2", type="Hospital", domain=TEST_DOMAIN, parent=cls.district) cls.user1 = bootstrap_web_user( username='******', phone_number='1111', location=cls.district, domain=TEST_DOMAIN, first_name='test', last_name='test1', user_data={ 'role': [] }, email='*****@*****.**', password='******' ) set_sms_notifications(TEST_DOMAIN, cls.user1, True) cls.national_user = bootstrap_web_user( username='******', phone_number='2222', location=cls.national, domain=TEST_DOMAIN, first_name='test', last_name='test2', user_data={ 'role': [] }, email='*****@*****.**', password='******' ) set_sms_notifications(TEST_DOMAIN, cls.national_user, True) cls.regional_user = bootstrap_web_user( username='******', phone_number='4444', location=cls.region, domain=TEST_DOMAIN, first_name='test', last_name='test4', user_data={ 'role': [] }, email='*****@*****.**', password='******' ) set_sms_notifications(TEST_DOMAIN, cls.regional_user, True) cls.product = Product(domain=TEST_DOMAIN, name='Test Product', code_='tp', unit='each') cls.product.save() cls.product2 = Product(domain=TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each') cls.product2.save() assign_products_to_location(cls.loc1, [cls.product]) assign_products_to_location(cls.loc2, [cls.product, cls.product2]) assign_products_to_location(cls.rms, [cls.product, cls.product2])
def setUp(self): super(EWSTestReminders, self).setUp() self.facility = make_loc('test-faciity', 'Test Facility', TEST_DOMAIN, 'Polyclinic') self.commodity = Product(domain=TEST_DOMAIN, name='Drug A', code_='ab', unit='cycle') self.commodity.save() self.commodity2 = Product(domain=TEST_DOMAIN, name='Drug B', code_='cd', unit='cycle') self.commodity2.save() self.sql_facility = self.facility.sql_location self.sql_facility.products = [] self.sql_facility.save()
def setUpClass(cls): domain = prepare_domain(TEST_DOMAIN) p = Product(domain=domain.name, name='Jadelle', code='jd', unit='each') p.save() p2 = Product(domain=domain.name, name='Male Condom', code='mc', unit='each') p2.save() p3 = Product(domain=domain.name, name='Lofem', code='lf', unit='each') p3.save() p4 = Product(domain=domain.name, name='Ng', code='ng', unit='each') p4.save() p5 = Product(domain=domain.name, name='Micro-G', code='mg', unit='each') p5.save() loc = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=domain.name) test.bootstrap(TEST_BACKEND, to_console=True) cls.user1 = bootstrap_user(username='******', first_name='test1', last_name='test1', domain=domain.name, home_loc=loc) cls.user2 = bootstrap_user(username='******', domain=domain.name, home_loc=loc, first_name='test2', last_name='test2', phone_number='222222', user_data={'role': 'In Charge'}) try: XFormInstance.get(docid='test-xform') except ResourceNotFound: xform = XFormInstance(_id='test-xform') xform.save() sql_location = loc.sql_location sql_location.products = SQLProduct.objects.filter(product_id=p5.get_id) sql_location.save() config = CommtrackConfig.for_domain(domain.name) config.actions.append( CommtrackActionConfig(action='receipts', keyword='rec', caption='receipts')) config.consumption_config = ConsumptionConfig(min_transactions=0, min_window=0, optimal_window=60) config.save()
def make_product(domain, name, code): p = Product() p.domain = domain p.name = name p.code = code.lower() p.save() return p
def test_incomplete_with_filter(self): """ User with product type filter will get notification all products of that type are missing reports. """ self.user.get_domain_membership( self.TEST_DOMAIN).program_id = self.program.get_id self.user.save() self.product.program_id = self.program.get_id self.product.save() create_stock_report(self.facility, {'tp': 100}, date=datetime.utcnow() - timedelta(days=365)) other_product = Product(domain=self.TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each', program_id=self.program.get_id) other_product.save() assign_products_to_location(self.facility, [self.product, other_product]) generated = list( OnGoingNonReporting(self.TEST_DOMAIN).get_notifications()) self.assertEqual(len(generated), 1) self.assertEqual(generated[0].user.get_id, self.user.get_id)
def _create_data(self, domain_name, i): product = Product(domain=domain_name, name='test-{}'.format(i)) product.save() location = make_location(domain=domain_name, site_code='testcode-{}'.format(i), name='test-{}'.format(i), location_type='facility') location.save() report = StockReport.objects.create( type='balance', domain=domain_name, form_id='fake', date=datetime.utcnow(), server_date=datetime.utcnow(), ) StockTransaction.objects.create( report=report, product_id=product.get_id, sql_product=SQLProduct.objects.get(product_id=product.get_id), section_id='stock', type='stockonhand', case_id=location.linked_supply_point().get_id, stock_on_hand=100) SMS.objects.create(domain=domain_name) Call.objects.create(domain=domain_name) SQLLastReadMessage.objects.create(domain=domain_name) ExpectedCallback.objects.create(domain=domain_name) PhoneNumber.objects.create(domain=domain_name, is_two_way=False, pending_verification=False) event = MessagingEvent.objects.create( domain=domain_name, date=datetime.utcnow(), source=MessagingEvent.SOURCE_REMINDER, content_type=MessagingEvent.CONTENT_SMS, status=MessagingEvent.STATUS_COMPLETED) MessagingSubEvent.objects.create( parent=event, date=datetime.utcnow(), recipient_type=MessagingEvent.RECIPIENT_CASE, content_type=MessagingEvent.CONTENT_SMS, status=MessagingEvent.STATUS_COMPLETED) SelfRegistrationInvitation.objects.create( domain=domain_name, phone_number='999123', token=uuid.uuid4().hex, expiration_date=datetime.utcnow().date(), created_date=datetime.utcnow()) backend = SQLMobileBackend.objects.create(domain=domain_name, is_global=False) SQLMobileBackendMapping.objects.create( domain=domain_name, backend_type=SQLMobileBackend.SMS, prefix=str(i), backend=backend) MobileBackendInvitation.objects.create(domain=domain_name, backend=backend)
def make_product(domain, name, code, program_id): p = Product() p.domain = domain p.name = name p.code = code.lower() p.program_id = program_id p.save() return p
def create_products(cls, domain_name, codes): for code in codes: product = Product(domain=domain_name, name=code, code=code, unit='each') product.save() setattr(cls, code, product)
def setUpClass(cls): super(IntraHealthTestCase, cls).setUpClass() cls.session_helper = connection_manager.get_session_helper( settings.SQL_REPORTING_DATABASE_URL) cls.engine = cls.session_helper.engine cls.domain = create_domain(TEST_DOMAIN) cls.region_type = LocationType.objects.create(domain=TEST_DOMAIN, name=u'Région') cls.district_type = LocationType.objects.create(domain=TEST_DOMAIN, name=u'District') cls.pps_type = LocationType.objects.create(domain=TEST_DOMAIN, name=u'PPS') cls.region = Location(domain=TEST_DOMAIN, name='Test region', location_type=u'Région') cls.region.save() cls.district = Location(domain=TEST_DOMAIN, name='Test district', location_type=u'District', parent=cls.region) cls.district.save() cls.pps = Location(domain=TEST_DOMAIN, name='Test PPS', location_type=u'PPS', parent=cls.district) cls.pps.save() cls.mobile_worker = create_mobile_worker(domain=TEST_DOMAIN, username='******', password='******', phone_number='777777') cls.mobile_worker.location_id = cls.pps.get_id cls.mobile_worker.save() cls.product = Product(_id=u'81457658bdedd663f8b0bdadb19d8f22', name=u'ASAQ Nourisson', domain=TEST_DOMAIN) cls.product2 = Product(_id=u'81457658bdedd663f8b0bdadb19d83d8', name=u'ASAQ Petit Enfant', domain=TEST_DOMAIN) cls.product.save() cls.product2.save()
def _create_data(self, domain_name): product = Product(domain=domain_name, name='test-product') product.save() location = Location(domain=domain_name, site_code='testcode', name='test1', location_type='facility') location.save() self.locations[domain_name] = location.get_id DeliveryGroupReport.objects.create(location_id=location.get_id, quantity=1, message='test', delivery_group='A') SupplyPointWarehouseRecord.objects.create( supply_point=location.get_id, create_date=datetime.utcnow()) Alert.objects.create(text='test', expires=datetime.utcnow(), date=datetime.utcnow(), location_id=location.get_id) organization_summary = OrganizationSummary.objects.create( date=datetime.utcnow(), location_id=location.get_id) GroupSummary.objects.create(org_summary=organization_summary) ProductAvailabilityData.objects.create(product=product.get_id, date=datetime.utcnow(), location_id=location.get_id) SupplyPointStatus.objects.create(location_id=location.get_id, status_type='del_fac', status_value='received') HistoricalLocationGroup.objects.create( location_id=location.sql_location, group='A', date=datetime.utcnow().date()) ReportRun.objects.create(domain=domain_name, start=datetime.utcnow(), end=datetime.utcnow(), start_run=datetime.utcnow()) ILSNotes.objects.create(location=location.sql_location, domain=domain_name, user_name='test', date=datetime.utcnow(), text='test') SupervisionDocument.objects.create(domain=domain_name, document='test', data_type='test', name='test')
def setUp(self): super(MissingReportNotificationTestCase, self).setUp() self.district = make_loc('test-district', 'Test District', self.TEST_DOMAIN, 'district') self.facility = make_loc('test-faciity', 'Test Facility', self.TEST_DOMAIN, 'Polyclinic', self.district) self.user = bootstrap_web_user( username='******', domain=self.TEST_DOMAIN, phone_number='+4444', location=self.district, email='*****@*****.**', password='******', user_data={} ) self.product = Product(domain=self.TEST_DOMAIN, name='Test Product', code_='tp', unit='each') self.product.save()
def test_incomplete_report2(self): create_stock_report(self.facility, {'tp': 100}, date=datetime.utcnow()) self.product.program_id = self.program2.get_id self.product.save() other_product = Product( domain=self.TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each', program_id=self.program.get_id ) other_product.save() assign_products_to_location(self.facility, [self.product, other_product]) generated = list(OnGoingNonReporting(self.TEST_DOMAIN).get_notifications()) self.assertEqual(len(generated), 0)
def test_partial_product_stockout(self): """Multiple products but only one is stocked out. Should be reported.""" other_product = Product(domain=self.TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each') other_product.save() assign_products_to_location(self.facility, [self.product, other_product]) create_stock_report(self.facility, {'tp': 0}) create_stock_report(self.facility, {'tp2': 10}) generated = list(OnGoingStockouts(self.TEST_DOMAIN).get_notifications()) self.assertEqual(len(generated), 1) self.assertEqual(generated[0].user.get_id, self.user.get_id)
def product_sync(self, ilsgateway_product): product = Product.get_by_code(self.domain, ilsgateway_product.sms_code) product_dict = { 'domain': self.domain, 'name': ilsgateway_product.name, 'code': ilsgateway_product.sms_code, 'unit': str(ilsgateway_product.units), 'description': ilsgateway_product.description, } if product is None: product = Product(**product_dict) product.save() else: if apply_updates(product, product_dict): product.save() return product
def _create_data(self, domain_name): product = Product(domain=domain_name, name='test-product') product.save() location = Location(domain=domain_name, site_code='testcode', name='test1', location_type='facility') location.save() self.locations[domain_name] = location.sql_location user = CommCareUser.create(domain=domain_name, username='******'.format(domain_name), password='******') FacilityInCharge.objects.create(user_id=user.get_id, location=location.sql_location)
def sync_openlmis_product(domain, program, lmis_product): product = get_product(domain, lmis_product) product_dict = { 'domain': domain, 'name': lmis_product.name, 'code': lmis_product.code, 'unit': str(lmis_product.unit), 'description': lmis_product.description, 'category': lmis_product.category, 'program_id': program._id, } if product is None: product = Product(**product_dict) product.save() else: if apply_updates(product, product_dict): product.save() return product
def setUp(self): super(UrgentNonReportingNotificationTestCase, self).setUp() self.product = Product(domain=self.TEST_DOMAIN, name='Test Product', code_='tp', unit='each', program_id=self.program.get_id) self.product.save() self.country = make_loc('test-country', 'Test country', self.TEST_DOMAIN, 'country') self.region = make_loc('test-region', 'Test Region', self.TEST_DOMAIN, 'region', parent=self.country) self.district = make_loc('test-district', 'Test District', self.TEST_DOMAIN, 'district', parent=self.region) self.facility = make_loc('test-facility', 'Test Facility', self.TEST_DOMAIN, 'Polyclinic', self.district) self.other_facility = make_loc('test-facility2', 'Test Facility 2', self.TEST_DOMAIN, 'Polyclinic', self.district) self.last_facility = make_loc('test-facility3', 'Test Facility 3', self.TEST_DOMAIN, 'Polyclinic', self.district) self.user = bootstrap_web_user( username='******', domain=self.TEST_DOMAIN, phone_number='+4444', location=self.region, email='*****@*****.**', password='******', user_data={} )
def create_product(cls, code, schedule, valid, expires, predecessor_id='', days_after_previous='', schedule_flag=''): p = Product(domain=cls.domain, name=code, code=code, product_data={ 'schedule': schedule, 'valid': valid, 'expires': expires, 'predecessor_id': predecessor_id, 'days_after_previous': days_after_previous, 'schedule_flag': schedule_flag, }) p.save() return p
def _create_data(self, domain_name, i): product = Product(domain=domain_name, name='test-{}'.format(i)) product.save() location = make_location(domain=domain_name, site_code='testcode-{}'.format(i), name='test-{}'.format(i), location_type='facility') location.save() SMS.objects.create(domain=domain_name) Call.objects.create(domain=domain_name) SQLLastReadMessage.objects.create(domain=domain_name) ExpectedCallback.objects.create(domain=domain_name) PhoneNumber.objects.create(domain=domain_name, is_two_way=False, pending_verification=False) event = MessagingEvent.objects.create( domain=domain_name, date=datetime.utcnow(), source=MessagingEvent.SOURCE_REMINDER, content_type=MessagingEvent.CONTENT_SMS, status=MessagingEvent.STATUS_COMPLETED) MessagingSubEvent.objects.create( parent=event, date=datetime.utcnow(), recipient_type=MessagingEvent.RECIPIENT_CASE, content_type=MessagingEvent.CONTENT_SMS, status=MessagingEvent.STATUS_COMPLETED) backend = SQLMobileBackend.objects.create(domain=domain_name, is_global=False) SQLMobileBackendMapping.objects.create( domain=domain_name, backend_type=SQLMobileBackend.SMS, prefix=str(i), backend=backend) MobileBackendInvitation.objects.create(domain=domain_name, backend=backend)
def _create_data(self, domain_name, i): product = Product(domain=domain_name, name='test-{}'.format(i)) product.save() location = Location(domain=domain_name, site_code='testcode-{}'.format(i), name='test-{}'.format(i), location_type='facility') location.save() SupplyPointCase.create_from_location(domain_name, location) report = StockReport.objects.create(type='balance', domain=domain_name, form_id='fake', date=datetime.utcnow()) StockTransaction.objects.create( report=report, product_id=product.get_id, sql_product=SQLProduct.objects.get(product_id=product.get_id), section_id='stock', type='stockonhand', case_id=location.linked_supply_point().get_id, stock_on_hand=100)
def product(self): return Product(domain=self.domain)
def setUpClass(cls): super(EWSScriptTest, cls).setUpClass() cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend() domain = prepare_domain(TEST_DOMAIN) p = Product(domain=domain.name, name='Jadelle', code='jd', unit='each') p.save() p2 = Product(domain=domain.name, name='Male Condom', code='mc', unit='each') p2.save() p3 = Product(domain=domain.name, name='Lofem', code='lf', unit='each') p3.save() p4 = Product(domain=domain.name, name='Ng', code='ng', unit='each') p4.save() p5 = Product(domain=domain.name, name='Micro-G', code='mg', unit='each') p5.save() Product(domain=domain.name, name='Ad', code='ad', unit='each').save() Product(domain=domain.name, name='Al', code='al', unit='each').save() Product(domain=domain.name, name='Qu', code='qu', unit='each').save() Product(domain=domain.name, name='Sp', code='sp', unit='each').save() Product(domain=domain.name, name='Rd', code='rd', unit='each').save() Product(domain=domain.name, name='Ov', code='ov', unit='each').save() Product(domain=domain.name, name='Ml', code='ml', unit='each').save() national = make_loc(code='country', name='Test national', type='country', domain=domain.name) region = make_loc(code='region', name='Test region', type='region', domain=domain.name, parent=national) loc = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=domain.name, parent=national) loc.save() rms2 = make_loc(code="wrms", name="Test RMS 2", type="Regional Medical Store", domain=domain.name, parent=region) rms2.save() cms = make_loc(code="cms", name="Central Medical Stores", type="Central Medical Store", domain=domain.name, parent=national) cms.save() loc2 = make_loc(code="tf", name="Test Facility", type="CHPS Facility", domain=domain.name, parent=region) loc2.save() supply_point_id = loc.linked_supply_point().get_id supply_point_id2 = loc2.linked_supply_point().get_id cls.user1 = bootstrap_user(username='******', first_name='test1', last_name='test1', domain=domain.name, home_loc=loc) cls.user2 = bootstrap_user(username='******', domain=domain.name, home_loc=loc2, first_name='test2', last_name='test2', phone_number='222222', user_data={'role': ['In Charge']}) FacilityInCharge.objects.create(user_id=cls.user2.get_id, location=loc2.sql_location) cls.user3 = bootstrap_user(username='******', domain=domain.name, home_loc=loc2, first_name='test3', last_name='test3', phone_number='333333') cls.rms_user = bootstrap_user(username='******', domain=domain.name, home_loc=rms2, first_name='test4', last_name='test4', phone_number='44444') cls.cms_user = bootstrap_user(username='******', domain=domain.name, home_loc=cms, first_name='test5', last_name='test5', phone_number='55555') cls.region_user = bootstrap_user(username='******', domain=domain.name, home_loc=region, first_name='test6', last_name='test6', phone_number='66666') cls.without_location = bootstrap_user(username='******', domain=domain.name, first_name='test7', last_name='test7', phone_number='77777') try: XFormInstance.get(docid='test-xform') except ResourceNotFound: xform = XFormInstance(_id='test-xform') xform.save() sql_location = loc.sql_location sql_location.products = [] sql_location.save() sql_location = loc2.sql_location sql_location.products = [] sql_location.save() sql_location = rms2.sql_location sql_location.products = [] sql_location.save() sql_location = cms.sql_location sql_location.products = [] sql_location.save() config = CommtrackConfig.for_domain(domain.name) config.use_auto_consumption = False config.individual_consumption_defaults = True config.actions.append( CommtrackActionConfig(action='receipts', keyword='rec', caption='receipts')) config.consumption_config = ConsumptionConfig( use_supply_point_type_default_consumption=True, exclude_invalid_periods=True) config.save() set_default_consumption_for_supply_point(TEST_DOMAIN, p2.get_id, supply_point_id, 8) set_default_consumption_for_supply_point(TEST_DOMAIN, p3.get_id, supply_point_id, 5) set_default_consumption_for_supply_point(TEST_DOMAIN, p2.get_id, supply_point_id2, 10) set_default_consumption_for_supply_point(TEST_DOMAIN, p3.get_id, supply_point_id2, 10) set_default_consumption_for_supply_point(TEST_DOMAIN, p5.get_id, supply_point_id2, 10)
def setUpClass(cls): super(TestReminders, cls).setUpClass() cls.backend, cls.sms_backend_mapping = setup_default_sms_test_backend() cls.domain = prepare_domain(TEST_DOMAIN) cls.loc1 = make_loc(code="garms", name="Test RMS", type="Regional Medical Store", domain=TEST_DOMAIN) cls.loc2 = make_loc(code="tf", name="Test Facility", type="Hospital", domain=TEST_DOMAIN) cls.region = make_loc(code="region", name="Test Region", type="region", domain=TEST_DOMAIN) cls.user1 = bootstrap_user( username='******', phone_number='1111', home_loc=cls.loc2, domain=TEST_DOMAIN, first_name='test', last_name='test1', user_data={ 'role': [] } ) cls.user2 = bootstrap_user( username='******', phone_number='2222', home_loc=cls.loc1, domain=TEST_DOMAIN, first_name='test', last_name='test2', user_data={ 'role': ['Other'], 'needs_reminders': "False" } ) cls.user3 = bootstrap_user( username='******', phone_number='3333', home_loc=cls.loc2, domain=TEST_DOMAIN, first_name='test', last_name='test3', user_data={ 'role': ['Nurse'], 'needs_reminders': "True" } ) cls.in_charge = bootstrap_user( username='******', phone_number='4444', home_loc=cls.loc2, domain=TEST_DOMAIN, first_name='test', last_name='test4', user_data={ 'role': ['In Charge'] } ) cls.web_user = bootstrap_web_user( domain=TEST_DOMAIN, username='******', password='******', email='*****@*****.**', location=cls.loc2, phone_number='5555' ) EWSExtension.objects.create( domain=TEST_DOMAIN, user_id=cls.web_user.get_id, sms_notifications=True, location_id=cls.loc2.get_id ) cls.web_user2 = bootstrap_web_user( domain=TEST_DOMAIN, username='******', password='******', email='*****@*****.**', location=cls.region, phone_number='6666' ) set_sms_notifications(TEST_DOMAIN, cls.web_user2, True) FacilityInCharge.objects.create( user_id=cls.in_charge.get_id, location=cls.loc2.sql_location ) cls.product = Product( domain=TEST_DOMAIN, name='Test Product', code_='tp', unit='each' ) cls.product.save() cls.product2 = Product( domain=TEST_DOMAIN, name='Test Product2', code_='tp2', unit='each' ) cls.product2.save() sql_product = SQLProduct.objects.get(product_id=cls.product.get_id) sql_product2 = SQLProduct.objects.get(product_id=cls.product2.get_id) sql_location1 = cls.loc1.sql_location sql_location2 = cls.loc2.sql_location sql_location1.products = [sql_product] sql_location2.products = [sql_product, sql_product2] sql_location1.save() sql_location2.save()