Exemplo n.º 1
0
 def test__irmc_scci_post__all_is_well(self, post):
     requests.Session.post.return_value = self.mockdata
     status, data, msg = irmc_scci_utils.irmc_scci_post(
         self.mod, "<xml><cmd/></xml>")
     self.assertEqual(self.mockdata.status_code, status)
     self.assertEqual(self.mockdata.content, data.content)
     self.assertEqual("OK", msg)
Exemplo n.º 2
0
 def test__irmc_scci_post__exception(self, post):
     requests.Session.post.side_effect = Timeout()
     status, data, msg = irmc_scci_utils.irmc_scci_post(
         self.mod, "<xml><cmd/></xml>")
     self.assertEqual(99, status)
     self.assertIn("Traceback", str(data))
     self.assertIn("POST request encountered exception (" + self.url + ")",
                   msg)
Exemplo n.º 3
0
 def test__irmc_scci_post__bad_body(self, post):
     requests.Session.post.return_value = self.mockdata
     requests.Session.post.content = "<xml><cmd></xml>"
     status, data, msg = irmc_scci_utils.irmc_scci_post(
         self.mod, "<xml><cmd></xml>")
     self.assertEqual(98, status)
     self.assertIn("Traceback", str(data))
     self.assertIn("POST request got invalid XML body", msg)
Exemplo n.º 4
0
 def test__irmc_scci_post__bad_status_without_reason(self, post):
     self.mockdata.status_code = 100
     self.mockdata.json.return_value = {'Data': 'mockdata'}
     requests.Session.post.return_value = self.mockdata
     status, data, msg = irmc_scci_utils.irmc_scci_post(
         self.mod, "<xml><cmd/></xml>")
     self.assertEqual(self.mockdata.status_code, status)
     self.assertEqual(self.mockdata.content, data.content)
     self.assertEqual("POST request was not successful (" + self.url + ").",
                      msg)