def test_delete_plan_invalid_args(self, stderr): with self.assertRaises(SystemExit) as cm: admin_plugin.delete_plan(["-s", self.service_name]) exc = cm.exception self.assertEqual(2, exc.code) stderr.write.assert_called_with( "delete-plan: error: too few arguments\n")
def test_delete_plan(self, stdout, Request, urlopen): request = mock.Mock() Request.return_value = request result = mock.Mock() result.getcode.return_value = 200 urlopen.return_value = result admin_plugin.delete_plan(["-s", self.service_name, "medium"]) Request.assert_called_with(self.target + "services/proxy/service/rpaas?" + "callback=/admin/plans/medium") request.add_header.assert_any_call("Authorization", "bearer " + self.token) self.assertEqual("DELETE", request.get_method()) stdout.write.assert_called_with("Plan successfully deleted\n")
def test_delete_plan_failure(self, stderr, Request, urlopen): request = mock.Mock() Request.return_value = request result = mock.Mock() result.getcode.return_value = 404 result.read.return_value = "plan not found\n" urlopen.return_value = result with self.assertRaises(SystemExit) as cm: admin_plugin.delete_plan(["-s", self.service_name, "medium"]) exc = cm.exception self.assertEqual(1, exc.code) Request.assert_called_with(self.target + "services/proxy/service/rpaas?" + "callback=/admin/plans/medium") request.add_header.assert_any_call("Authorization", "bearer " + self.token) self.assertEqual("DELETE", request.get_method()) stderr.write.assert_called_with("ERROR: plan not found\n")
def test_delete_plan_invalid_args(self, stderr): with self.assertRaises(SystemExit) as cm: admin_plugin.delete_plan(["-s", self.service_name]) exc = cm.exception self.assertEqual(2, exc.code) stderr.write.assert_called_with("delete-plan: error: too few arguments\n")