def test_location_fixture_generator(self): """ This tests the location XML fixture generator. It specifically ensures that no duplicate XML nodes are generated when all locations have a parent and multiple locations are enabled. """ self.domain.commtrack_enabled = True self.domain.save() self.loc.delete() state = make_loc("teststate1", type="state", domain=self.domain.name) district = make_loc("testdistrict1", type="district", domain=self.domain.name, parent=state) block = make_loc("testblock1", type="block", domain=self.domain.name, parent=district) village = make_loc("testvillage1", type="village", domain=self.domain.name, parent=block) outlet1 = make_loc("testoutlet1", type="outlet", domain=self.domain.name, parent=village) outlet2 = make_loc("testoutlet2", type="outlet", domain=self.domain.name, parent=village) outlet3 = make_loc("testoutlet3", type="outlet", domain=self.domain.name, parent=village) self.user.set_location(outlet2) self.user.add_location_delegate(outlet1) self.user.add_location_delegate(outlet2) self.user.add_location_delegate(outlet3) self.user.add_location_delegate(state) self.user.save() fixture = location_fixture_generator(self.user, "2.0") self.assertEquals(len(fixture[0].findall(".//state")), 1) self.assertEquals(len(fixture[0].findall(".//outlet")), 3)
def test_location_fixture_generator(self): """ This tests the location XML fixture generator. It specifically ensures that no duplicate XML nodes are generated when all locations have a parent and multiple locations are enabled. """ self.domain.commtrack_enabled = True self.domain.save() self.loc.delete() state = make_loc( 'teststate1', type='state', domain=self.domain.name ) district = make_loc( 'testdistrict1', type='district', domain=self.domain.name, parent=state ) block = make_loc( 'testblock1', type='block', domain=self.domain.name, parent=district ) village = make_loc( 'testvillage1', type='village', domain=self.domain.name, parent=block ) outlet1 = make_loc( 'testoutlet1', type='outlet', domain=self.domain.name, parent=village ) outlet2 = make_loc( 'testoutlet2', type='outlet', domain=self.domain.name, parent=village ) outlet3 = make_loc( 'testoutlet3', type='outlet', domain=self.domain.name, parent=village ) self.user.set_location(outlet2) self.user.add_location_delegate(outlet1) self.user.add_location_delegate(outlet2) self.user.add_location_delegate(outlet3) self.user.add_location_delegate(state) self.user.save() fixture = location_fixture_generator(self.user, '2.0') self.assertEquals(len(fixture[0].findall('.//state')), 1) self.assertEquals(len(fixture[0].findall('.//outlet')), 3)
def test_location_fixture_generator(self): """ This tests the location XML fixture generator. It specifically ensures that no duplicate XML nodes are generated when all locations have a parent and multiple locations are enabled. """ self.domain.commtrack_enabled = True self.domain.save() self.loc.delete() state = make_loc( 'teststate1', type='state', domain=self.domain.name ) district = make_loc( 'testdistrict1', type='district', domain=self.domain.name, parent=state ) block = make_loc( 'testblock1', type='block', domain=self.domain.name, parent=district ) village = make_loc( 'testvillage1', type='village', domain=self.domain.name, parent=block ) outlet1 = make_loc( 'testoutlet1', type='outlet', domain=self.domain.name, parent=village ) outlet2 = make_loc( 'testoutlet2', type='outlet', domain=self.domain.name, parent=village ) outlet3 = make_loc( 'testoutlet3', type='outlet', domain=self.domain.name, parent=village ) self.user.set_location(outlet2) self.user.add_location_delegate(outlet1) self.user.add_location_delegate(outlet2) self.user.add_location_delegate(outlet3) self.user.add_location_delegate(state) self.user.save() fixture = location_fixture_generator(self.user.to_ota_restore_user(), '2.0') self.assertEquals(len(fixture[0].findall('.//state')), 1) self.assertEquals(len(fixture[0].findall('.//outlet')), 3)
def test_location_fixture_generator_domain_no_locations(self): """ Ensures that a domain that doesn't use locations doesn't send an empty location fixture """ self.domain.save() self.loc.delete() fixture = location_fixture_generator(self.user.to_ota_restore_user(), '2.0') self.assertEqual(len(fixture), 0)
def test_location_fixture_generator_domain_no_locations(self): """ Ensures that a domain that doesn't use locations doesn't send an empty location fixture """ self.domain.save() self.loc.delete() fixture = location_fixture_generator(self.user.to_ota_restore_user(), '2.0') self.assertEqual(len(fixture), 0)
def test_location_fixture_generator_no_user_location(self): """ Ensures that a user without a location will still receive an empty fixture """ self.domain.commtrack_enabled = True self.domain.save() self.loc.delete() fixture = location_fixture_generator(self.user.to_ota_restore_user(), '2.0') self.assertEqual(len(fixture), 1) self.assertEquals(len(fixture[0].findall('.//state')), 0)
def test_location_fixture_generator_no_user_location(self): """ Ensures that a user without a location will still receive an empty fixture """ self.domain.commtrack_enabled = True self.domain.save() self.loc.delete() fixture = location_fixture_generator(self.user.to_ota_restore_user(), '2.0') self.assertEqual(len(fixture), 1) self.assertEquals(len(fixture[0].findall('.//state')), 0)