def test_edit_non_facility_location(self):
        with open(os.path.join(self.datapath, 'sample_locations.json')) as f:
            location = Location(json.loads(f.read())[0])

        ewsghana_location = self.api_object.location_sync(location)
        self.assertEqual(ewsghana_location.name, "Test country")
        self.assertEqual(ewsghana_location.site_code, "testcountry")

        location.name = "edited"
        location.code = "edited"
        ewsghana_location = self.api_object.location_sync(location)

        self.assertEqual(ewsghana_location.name, "edited")
        self.assertEqual(ewsghana_location.site_code, "edited")
Exemple #2
0
    def test_edit_non_facility_location(self):
        with open(os.path.join(self.datapath, 'sample_locations.json')) as f:
            location = Location(json.loads(f.read())[0])

        ewsghana_location = self.api_object.location_sync(location)
        self.assertEqual(ewsghana_location.name, "Test country")
        self.assertEqual(ewsghana_location.site_code, "testcountry")

        location.name = "edited"
        location.code = "edited"
        ewsghana_location = self.api_object.location_sync(location)

        self.assertEqual(ewsghana_location.name, "edited")
        self.assertEqual(ewsghana_location.site_code, "edited")
    def test_edit_reporting_location(self):
        with open(os.path.join(self.datapath, 'sample_locations.json')) as f:
            location = Location(json.loads(f.read())[1])

        self.api_object.location_sync(location)
        location.name = 'edited'
        location.code = 'edited'
        edited = self.api_object.location_sync(location)
        # shouldn't change because we use name and code from supply point not from location
        self.assertEqual(edited.name, 'Central Regional Medical Store')
        self.assertEqual(edited.site_code, 'crms')

        location.supply_points[0].name = 'edited'
        location.supply_points[0].code = 'edited'
        location.supply_points[0].products = ['alk', 'abc', 'ad']
        edited = self.api_object.location_sync(location)
        self.assertEqual(edited.name, 'edited')
        self.assertEqual(edited.site_code, 'edited')
        self.assertEqual(edited.sql_location.products.count(), 3)
        self.assertListEqual(list(edited.sql_location.products.values_list('code', flat=True).order_by('code')),
                             ['abc', 'ad', 'alk'])
Exemple #4
0
    def test_edit_reporting_location(self):
        with open(os.path.join(self.datapath, 'sample_locations.json')) as f:
            location = Location(json.loads(f.read())[1])

        self.api_object.location_sync(location)
        location.name = 'edited'
        location.code = 'edited'
        edited = self.api_object.location_sync(location)
        # shouldn't change because we use name and code from supply point not from location
        self.assertEqual(edited.name, 'Central Regional Medical Store')
        self.assertEqual(edited.site_code, 'crms')

        location.supply_points[0].name = 'edited'
        location.supply_points[0].code = 'edited'
        location.supply_points[0].products = ['alk', 'abc', 'ad']
        edited = self.api_object.location_sync(location)
        self.assertEqual(edited.name, 'edited')
        self.assertEqual(edited.site_code, 'edited')
        self.assertEqual(edited.sql_location.products.count(), 3)
        self.assertListEqual(
            list(
                edited.sql_location.products.values_list(
                    'code', flat=True).order_by('code')), ['abc', 'ad', 'alk'])