Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    def test_facility_in_district(self):
        """Facility location can be any child of the district."""
        make_loc('test-faciity2', 'Test Facility2', self.TEST_DOMAIN, 'Polyclinic', self.district)
        generated = list(OnGoingNonReporting(self.TEST_DOMAIN).get_notifications())

        self.assertEqual(len(generated), 1)

        self.assertEqual(generated[0].user.get_id, self.user.get_id)
Esempio n. 4
0
    def test_facility_in_district(self):
        """Facility location can be any child of the district."""
        make_loc('test-faciity2', 'Test Facility2', self.TEST_DOMAIN, 'Polyclinic', self.district)
        generated = list(OnGoingNonReporting(self.TEST_DOMAIN).get_notifications())

        self.assertEqual(len(generated), 1)

        self.assertEqual(generated[0].user.get_id, self.user.get_id)
Esempio n. 5
0
 def setUp(self):
     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()
Esempio n. 6
0
 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()
Esempio n. 7
0
 def setUp(self):
     self.district = make_loc('test-district', 'Test District', self.TEST_DOMAIN, 'district')
     self.user = bootstrap_web_user(
         username='******', domain=self.TEST_DOMAIN, phone_number='+4444', location=self.district,
         email='*****@*****.**', password='******'
     )
     set_sms_notifications(self.domain, self.user, True)
     self.notification = Notification(self.TEST_DOMAIN, self.user, 'test')
Esempio n. 8
0
 def setUp(self):
     super(SMSNotificationTestCase, self).setUp()
     self.district = make_loc('test-district', 'Test District', self.TEST_DOMAIN, 'district')
     self.user = bootstrap_web_user(
         username='******', domain=self.TEST_DOMAIN, phone_number='+4444', location=self.district,
         email='*****@*****.**', password='******'
     )
     set_sms_notifications(self.domain, self.user, True)
     self.notification = Notification(self.TEST_DOMAIN, self.user, 'test')
Esempio n. 9
0
    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])
Esempio n. 10
0
    def setUp(self):
        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()
Esempio n. 11
0
    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()
Esempio n. 12
0
    def setUp(self):
        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={}
        )
Esempio n. 13
0
    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={}
        )
Esempio n. 14
0
    def setUpClass(cls):
        cls.domain = prepare_domain(TEST_DOMAIN)
        cls.sms_backend_mapping, cls.backend = create_backend()

        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])