def test_remove_geofence(self, name): policy = AuthPolicy() retrieved = policy.get_policy() self.assertEqual(len(retrieved['factors']), 1) self.assertEqual(policy.geofences, []) policy.add_geofence(MagicMock(spec=int), MagicMock(spec=int), MagicMock(spec=int), name) self.assertEqual(len(policy.geofences), 1) retrieved = policy.get_policy() self.assertEqual(len(retrieved['factors']), 2) self.assertEqual(len(retrieved['factors'][1]['attributes']['locations']), 1) policy.remove_geofence(name) self.assertEqual(policy.geofences, []) retrieved = policy.get_policy() self.assertEqual(len(retrieved['factors'][1]['attributes']['locations']), 0)
def test_remove_geofence(self, name): policy = AuthPolicy() retrieved = policy.get_policy() self.assertEqual(len(retrieved['factors']), 1) self.assertEqual(policy.geofences, []) policy.add_geofence(MagicMock(spec=int), MagicMock(spec=int), MagicMock(spec=int), name) self.assertEqual(len(policy.geofences), 1) retrieved = policy.get_policy() self.assertEqual(len(retrieved['factors']), 2) self.assertEqual( len(retrieved['factors'][1]['attributes']['locations']), 1) policy.remove_geofence(name) self.assertEqual(policy.geofences, []) retrieved = policy.get_policy() self.assertEqual( len(retrieved['factors'][1]['attributes']['locations']), 0)
def test_remove_invalid_geofence(self): policy = AuthPolicy() policy.add_geofence(1, 1, 2) with self.assertRaises(InvalidGeoFenceName): policy.remove_geofence(MagicMock(spec=str))
def test_remove_partially_invalid_geofence(self): policy = AuthPolicy() policy.add_geofence(1, 1, 2, 'name') policy.geofences.pop() with self.assertRaises(InvalidGeoFenceName): policy.remove_geofence('name')