def test__irmc_redfish_post__bad_status_without_reason(self, post): requests.Session.post.return_value = self.mockdata self.mockdata.status_code = 100 status, data, msg = irmc.irmc_redfish_post(self.mod, "redfish_path", json.dumps({'Patch': 'mockpatch'})) self.assertEqual(self.mockdata.status_code, status) self.assertEqual(self.mockdata.json.return_value, data.json.return_value) self.assertEqual("POST request was not successful (" + self.url + ").", msg)
def test__irmc_redfish_post__exception(self, post): requests.Session.post.side_effect = Timeout() status, data, msg = irmc.irmc_redfish_post(self.mod, "redfish_path", json.dumps({'Patch': 'mockpatch'})) self.assertEqual(99, status) self.assertIn("Traceback", str(data)) self.assertIn("POST request encountered exception (" + self.url + ")", msg)
def test__irmc_redfish_post__bad_body(self, post): requests.Session.post.return_value = self.mockdata status, data, msg = irmc.irmc_redfish_post(self.mod, "redfish_path", "{ 'Patch': 'mockpatch' }") self.assertEqual(98, status) self.assertIn("Traceback", str(data)) self.assertIn("POST request got invalid JSON body", msg)
def test__irmc_redfish_post__all_is_well(self, post): requests.Session.post.return_value = self.mockdata status, data, msg = irmc.irmc_redfish_post(self.mod, "redfish_path", json.dumps({'Patch': 'mockpatch'})) self.assertEqual(self.mockdata.status_code, status) self.assertEqual(self.mockdata.json.return_value, data.json.return_value) self.assertEqual("OK", msg)