def setUpClass(cls): super(RemindersTest, cls).bypass_setUpClass() cls.sms_backend, cls.sms_backend_mapping = setup_default_sms_test_backend( ) cls.domain = prepare_domain(TEST_DOMAIN) cls.district = make_loc(code="dis1", name="Test District 1", type="DISTRICT", domain=TEST_DOMAIN) cls.facility = make_loc(code="loc1", name="Test Facility 1", type="FACILITY", domain=TEST_DOMAIN, parent=cls.district) cls.facility_sp_id = cls.facility.sql_location.supply_point_id cls.user1 = bootstrap_user(cls.facility, username='******', domain=TEST_DOMAIN, home_loc='loc1', phone_number='5551234', first_name='test', last_name='Test') create_products(cls, TEST_DOMAIN, [ "id", "dp", "fs", "md", "ff", "dx", "bp", "pc", "qi", "jd", "mc", "ip" ])
def setUpClass(cls): cls.sms_backend, cls.sms_backend_mapping = setup_default_sms_test_backend() cls.domain = prepare_domain(TEST_DOMAIN) cls.district = make_loc(code="dis1", name="Test District 1", type="DISTRICT", domain=TEST_DOMAIN) cls.facility = make_loc(code="loc1", name="Test Facility 1", type="FACILITY", domain=TEST_DOMAIN, parent=cls.district) cls.user1 = bootstrap_user( cls.district, username='******', domain=TEST_DOMAIN, home_loc='dis1', phone_number='5551234', first_name='test', last_name='Test' )
def setUpClass(cls): super(ILSTestScript, cls).setUpClass() cls.sms_backend, cls.sms_backend_mapping = setup_default_sms_test_backend() domain = prepare_domain(TEST_DOMAIN) USE_SMS_WITH_INACTIVE_CONTACTS.set(TEST_DOMAIN, True, namespace='domain') mohsw = make_loc(code="moh1", name="Test MOHSW 1", type="MOHSW", domain=domain.name) msdzone = make_loc(code="msd1", name="MSD Zone 1", type="MSDZONE", domain=domain.name, parent=mohsw) region = make_loc(code="reg1", name="Test Region 1", type="REGION", domain=domain.name, parent=msdzone) cls.district = make_loc(code="dis1", name="Test District 1", type="DISTRICT", domain=domain.name, parent=region) cls.district2 = make_loc(code="d10101", name="Test District 2", type="DISTRICT", domain=domain.name, parent=region) cls.district3 = make_loc(code="d10102", name="TESTDISTRICT", type="DISTRICT", domain=domain.name, parent=region) cls.facility = make_loc(code="loc1", name="Test Facility 1", type="FACILITY", domain=domain.name, parent=cls.district, metadata={'group': 'A'}) cls.facility_sp_id = cls.facility.sql_location.supply_point_id facility2 = make_loc(code="loc2", name="Test Facility 2", type="FACILITY", domain=domain.name, parent=cls.district, metadata={'group': 'B'}) cls.facility3 = make_loc( code="d31049", name="Test Facility 3", type="FACILITY", domain=domain.name, parent=cls.district, metadata={'group': 'C'} ) cls.user1 = bootstrap_user( cls.facility, username='******', domain=domain.name, home_loc='loc1', phone_number='5551234', first_name='stella', last_name='Test', language='sw' ) cls.en_user1 = bootstrap_user( cls.facility, username='******', domain=domain.name, home_loc='loc1', phone_number='5551235', first_name='stella', last_name='Test English', language='en' ) bootstrap_user(facility2, username='******', domain=domain.name, home_loc='loc2', phone_number='5555678', first_name='bella', last_name='Test', language='sw') bootstrap_user(cls.district, username='******', domain=domain.name, home_loc='dis1', phone_number='555', first_name='trella', last_name='Test', language='sw') bootstrap_user(cls.district, username='******', domain=domain.name, phone_number='111', first_name='MSD', last_name='Person', user_data={'role': 'MSD'}, language='sw') for x in range(1, 4): bootstrap_user( cls.facility3, username='******'.format(x), domain=domain.name, phone_number=str(32346 + x), first_name='Person {}'.format(x), last_name='Person {}'. format(x), home_loc='d31049', language='sw' ) bootstrap_user( cls.district2, username='******'.format(x), domain=domain.name, phone_number=str(32349 + x), first_name='dPerson {}'.format(x), last_name='dPerson {}'. format(x), home_loc='d10101', language='sw' ) create_products(cls, domain.name, ["id", "dp", "fs", "md", "ff", "dx", "bp", "pc", "qi", "jd", "mc", "ip"])
def setUpClass(cls): super(TestReportGroups, cls).setUpClass() cls.sms_backend, cls.sms_backend_mapping = setup_default_sms_test_backend() cls.domain = prepare_domain(TEST_DOMAIN) cls.district = make_loc(code="dis1", name="Test District 1", type="DISTRICT", domain=TEST_DOMAIN) cls.facility = make_loc(code="loc1", name="Test Facility 1", type="FACILITY", domain=TEST_DOMAIN, parent=cls.district) cls.user1 = bootstrap_user( cls.district, username='******', domain=TEST_DOMAIN, home_loc='dis1', phone_number='5551234', first_name='test', last_name='Test' )
def setUpClass(cls): cls.sms_backend, cls.sms_backend_mapping = setup_default_sms_test_backend() cls.domain = prepare_domain(TEST_DOMAIN) cls.district = make_loc(code="dis1", name="Test District 1", type="DISTRICT", domain=TEST_DOMAIN) cls.facility = make_loc(code="loc1", name="Test Facility 1", type="FACILITY", domain=TEST_DOMAIN, parent=cls.district) cls.facility_sp_id = cls.facility.sql_location.supply_point_id cls.user1 = bootstrap_user( cls.facility, username='******', domain=TEST_DOMAIN, home_loc='loc1', phone_number='5551234', first_name='test', last_name='Test' ) create_products(cls, TEST_DOMAIN, ["id", "dp", "fs", "md", "ff", "dx", "bp", "pc", "qi", "jd", "mc", "ip"])
def setUpClass(cls): super(TestStockOut, cls).setUpClass() cls.facility2 = make_loc(code="loc2", name="Test Facility 2", type="FACILITY", domain=TEST_DOMAIN, parent=cls.district) cls.user2 = bootstrap_user( cls.facility2, username='******', domain=TEST_DOMAIN, home_loc='loc2', phone_number='5551235', first_name='test', last_name='Test' ) SLABConfig.objects.create( is_pilot=True, sql_location=cls.facility.sql_location ) slab_config = SLABConfig.objects.create( is_pilot=True, sql_location=cls.facility2.sql_location ) slab_config.closest_supply_points.add(cls.facility.sql_location) slab_config.save() config = CommtrackConfig.for_domain(TEST_DOMAIN) config.use_auto_consumption = False config.individual_consumption_defaults = True 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, cls.id.get_id, cls.facility_sp_id, 100) set_default_consumption_for_supply_point(TEST_DOMAIN, cls.dp.get_id, cls.facility_sp_id, 100) set_default_consumption_for_supply_point(TEST_DOMAIN, cls.ip.get_id, cls.facility_sp_id, 100)
def test_location_created_after_facility_processing(self): start_date = datetime(2015, 9, 1) end_date = datetime.utcnow() with mock.patch('custom.ilsgateway.tanzania.warehouse.updater.default_start_date', return_value=start_date), \ mock.patch('custom.ilsgateway.tasks.default_start_date', return_value=start_date), \ mock.patch('custom.ilsgateway.tasks.get_start_date', return_value=start_date): run = ReportRun.objects.create(start=start_date, end=end_date, start_run=datetime.utcnow(), domain=self.domain.name) process_facility_warehouse_data(self.facility1, start_date, end_date, run) facility = make_loc(code='new_facility', name='New Facility', domain=self.domain.name, type='FACILITY', parent=self.district1, metadata={'group': 'A'}) process_non_facility_warehouse_data(self.district1, start_date, end_date, run) self.assertEqual( OrganizationSummary.objects.filter( date__lte=datetime(2015, 9, 3)).count(), 2) facility.delete()
def setUpClass(cls): super(TestReportSummaryBase, cls).setUpClass() delete_domain_phone_numbers(TEST_DOMAIN) cls.sms_backend, cls.sms_backend_mapping = setup_default_sms_test_backend() cls.domain = prepare_domain(TEST_DOMAIN) cls.district = make_loc(code="dis1", name="TEST DISTRICT", type="DISTRICT", domain=TEST_DOMAIN, metadata={'group': DeliveryGroups().current_submitting_group()}) cls.facility = make_loc(code="d10001", name="Test Facility 1", type="FACILITY", domain=TEST_DOMAIN, parent=cls.district, metadata={'group': DeliveryGroups().current_submitting_group()}) cls.facility2 = make_loc(code="d10002", name="Test Facility 2", type="FACILITY", domain=TEST_DOMAIN, parent=cls.district, metadata={'group': DeliveryGroups().current_delivering_group()}) cls.facility3 = make_loc(code="d10003", name="Test Facility 3", type="FACILITY", domain=TEST_DOMAIN, parent=cls.district, metadata={'group': DeliveryGroups().current_submitting_group()}) cls.facilities = [cls.facility, cls.facility2, cls.facility3] cls.district_user = bootstrap_user( cls.district, username='******', domain=TEST_DOMAIN, home_loc='dis1', phone_number='1234', first_name='test', last_name='Test' ) cls.contact1 = bootstrap_user( cls.facility, username='******', domain=TEST_DOMAIN, home_loc='d10001', phone_number='1235', first_name='test', last_name='Test' ) cls.contact2 = bootstrap_user( cls.facility2, username='******', domain=TEST_DOMAIN, home_loc='d10002', phone_number='1236', first_name='test', last_name='Test' ) cls.contact3 = bootstrap_user( cls.facility3, username='******', domain=TEST_DOMAIN, home_loc='d10003', phone_number='1237', first_name='test', last_name='Test' ) for facility in cls.facilities: facility.metadata['group'] = cls.relevant_group() facility.save() create_products(cls, TEST_DOMAIN, ["id", "dp", "fs", "md", "ff", "dx", "bp", "pc", "qi", "jd", "mc", "ip"])
def test_location_created_after_facility_processing(self): start_date = datetime(2015, 9, 1) end_date = datetime.utcnow() with mock.patch('custom.ilsgateway.tanzania.warehouse.updater.default_start_date', return_value=start_date), \ mock.patch('custom.ilsgateway.tasks.default_start_date', return_value=start_date), \ mock.patch('custom.ilsgateway.tasks.get_start_date', return_value=start_date): run = ReportRun.objects.create(start=start_date, end=end_date, start_run=datetime.utcnow(), domain=self.domain.name) process_facility_warehouse_data(self.facility1, start_date, end_date, run) facility = make_loc(code='new_facility', name='New Facility', domain=self.domain.name, type='FACILITY', parent=self.district1, metadata={'group': 'A'}) process_non_facility_warehouse_data(self.district1, start_date, end_date, run) self.assertEqual(OrganizationSummary.objects.filter(date__lte=datetime(2015, 9, 3)).count(), 2) facility.delete()
def setUpClass(cls): prepare_domain(TEST_DOMAIN) cls.mohsw = make_loc(code='mohsw', name='mohsw', domain=TEST_DOMAIN, type='MOHSW') cls.region1 = make_loc(code='region1', name='Test Region 1', domain=TEST_DOMAIN, type='REGION', parent=cls.mohsw) cls.region2 = make_loc(code='region2', name='Test Region 2', domain=TEST_DOMAIN, type='REGION', parent=cls.mohsw) cls.district1 = make_loc(code='district1', name='Test District 1', domain=TEST_DOMAIN, type='DISTRICT', parent=cls.region1) cls.district2 = make_loc(code='district2', name='Test District 2', domain=TEST_DOMAIN, type='DISTRICT', parent=cls.region2) cls.facility1 = make_loc(code='facility1', name='Test Facility 1', domain=TEST_DOMAIN, type='FACILITY', parent=cls.district1, metadata={'group': 'A'}) cls.facility2 = make_loc(code='facility2', name='Test Facility 2', domain=TEST_DOMAIN, type='FACILITY', parent=cls.district2, metadata={'group': 'C'}) create_products(cls, TEST_DOMAIN, ['dx', 'al', 'ab']) date = datetime(2015, 9, 2) create_stock_report(cls.facility1, {'dx': 10, 'al': 0, 'ab': 15}, date) create_stock_report(cls.facility2, {'dx': 10, 'al': 20, 'ab': 15}, date) SupplyPointStatus.objects.create( status_type=SupplyPointStatusTypes.DELIVERY_FACILITY, status_value=SupplyPointStatusValues.RECEIVED, status_date=date, location_id=cls.facility1.get_id ) SupplyPointStatus.objects.create( status_type=SupplyPointStatusTypes.R_AND_R_FACILITY, status_value=SupplyPointStatusValues.SUBMITTED, status_date=date, location_id=cls.facility2.get_id ) StockDataCheckpoint.objects.create( domain=TEST_DOMAIN, api='test', date=date, limit=1000, offset=0 )
def setUpClass(cls): super(TestReportRunner, cls).setUpClass() cls.domain = prepare_domain(TEST_DOMAIN) cls.mohsw = make_loc(code='mohsw', name='mohsw', domain=TEST_DOMAIN, type='MOHSW') cls.region1 = make_loc(code='region1', name='Test Region 1', domain=TEST_DOMAIN, type='REGION', parent=cls.mohsw) cls.region2 = make_loc(code='region2', name='Test Region 2', domain=TEST_DOMAIN, type='REGION', parent=cls.mohsw) cls.district1 = make_loc(code='district1', name='Test District 1', domain=TEST_DOMAIN, type='DISTRICT', parent=cls.region1) cls.district2 = make_loc(code='district2', name='Test District 2', domain=TEST_DOMAIN, type='DISTRICT', parent=cls.region2) cls.facility1 = make_loc(code='facility1', name='Test Facility 1', domain=TEST_DOMAIN, type='FACILITY', parent=cls.district1, metadata={'group': 'A'}) cls.facility2 = make_loc(code='facility2', name='Test Facility 2', domain=TEST_DOMAIN, type='FACILITY', parent=cls.district2, metadata={'group': 'C'}) create_products(cls, TEST_DOMAIN, ['dx', 'al', 'ab']) date = datetime(2015, 9, 2) create_stock_report(cls.facility1, {'dx': 10, 'al': 0, 'ab': 15}, date) create_stock_report(cls.facility2, {'dx': 10, 'al': 20, 'ab': 15}, date) SupplyPointStatus.objects.create( status_type=SupplyPointStatusTypes.DELIVERY_FACILITY, status_value=SupplyPointStatusValues.RECEIVED, status_date=date, location_id=cls.facility1.get_id ) SupplyPointStatus.objects.create( status_type=SupplyPointStatusTypes.R_AND_R_FACILITY, status_value=SupplyPointStatusValues.SUBMITTED, status_date=date, location_id=cls.facility2.get_id )