def test_delete_sub_when_state_locking(self): subscription_locking_data = create_subscription_data('MG_locking') subscription_locking_data.measurement_groups[ 0].measurement_group_name = 'locking' subscription_locking_data.measurement_groups[ 0].administrative_state = 'LOCKING' db.session.add(subscription_locking_data) db.session.add(subscription_locking_data.measurement_groups[0]) db.session.commit() db.session.remove() message, status_code = delete_subscription_by_name('MG_locking') self.assertEqual(status_code, HTTPStatus.CONFLICT.value) self.assertEqual( subscription_service.query_subscription_by_name( 'MG_locking').subscription_name, 'MG_locking')
def test_delete_sub_when_state_locked(self): subscription_unlocked_data = create_subscription_data('MG_locked') subscription_unlocked_data.measurement_groups[ 0].measurement_group_name = 'lock' subscription_unlocked_data.measurement_groups[ 0].administrative_state = 'LOCKED' db.session.add(subscription_unlocked_data) db.session.add(subscription_unlocked_data.measurement_groups[0]) db.session.commit() db.session.remove() none_type, status_code = delete_subscription_by_name('MG_locked') self.assertEqual(none_type, None) self.assertEqual(status_code, HTTPStatus.NO_CONTENT.value) self.assertEqual( subscription_service.query_subscription_by_name('MG_locked'), None)
def test_delete_sub_exception(self): error, status_code = delete_subscription_by_name('None') self.assertEqual(status_code, HTTPStatus.INTERNAL_SERVER_ERROR.value)
def test_delete_sub_none(self): message, status_code = delete_subscription_by_name('None') self.assertEqual(message['error'], 'Subscription is not defined with name None') self.assertEqual(status_code, HTTPStatus.NOT_FOUND.value)