Exemple #1
0
 def test_valid_json(self, m):
     text = '{"text": "Sample json"}'
     headers = {"Content-type": "application/json"}
     m.register_uri("GET", "http://example.com", text=text, headers=headers)
     resp = requests.get("http://example.com")
     test = FakeTestObject(resp)
     signal = valid_content(test)
     self.assertEqual("VALID_JSON", signal.slug)
 def test_valid_json(self, m):
     text = u'{"text": "Sample json"}'
     headers = {"Content-type": "application/json"}
     m.register_uri("GET", "http://example.com", text=text, headers=headers)
     resp = requests.get("http://example.com")
     test = FakeTestObject(resp)
     signal = valid_content(test)
     self.assertEqual("VALID_JSON", signal.slug)
 def test_valid_xml(self, m):
     text = u"""<note>\n
                  <to>Tove</to>\n
                  <from>Jani</from>\n
                  <heading>Reminder</heading>\n
                  <body>Don't forget me this weekend!</body>\n
                  </note>"""
     headers = {"Content-type": "application/xml"}
     m.register_uri("GET",
                    "http://example.com",
                    text=textwrap.dedent(text),
                    headers=headers)
     resp = requests.get("http://example.com")
     test = FakeTestObject(resp)
     signal = valid_content(test)
     self.assertEqual("VALID_XML", signal.slug)
 def test_valid_xml(self, m):
     text = u"""<note>\n
                  <to>Tove</to>\n
                  <from>Jani</from>\n
                  <heading>Reminder</heading>\n
                  <body>Don't forget me this weekend!</body>\n
                  </note>"""
     headers = {"Content-type": "application/xml"}
     m.register_uri(
         "GET",
         "http://example.com",
         text=textwrap.dedent(text),
         headers=headers)
     resp = requests.get("http://example.com")
     test = FakeTestObject(resp)
     signal = valid_content(test)
     self.assertEqual("VALID_XML", signal.slug)
 def test_invalid_xml(self, m):
     text = u"""<xml version=='1.0' encoding==UTF-8'?>
                  <!DOCTYPE note SYSTEM 'Note.dtd'>
                  <note>
                  <to>Tove</to>
                  <from>Jani</from>
                  <heading>Reminder</heading>
                  <body>Don't forget me this weekend!</body>
                  html>"""
     headers = {"Content-type": "application/xml"}
     m.register_uri("GET",
                    "http://example.com",
                    text=textwrap.dedent(text),
                    headers=headers)
     resp = requests.get("http://example.com")
     test = FakeTestObject(resp)
     signal = valid_content(test)
     self.assertEqual("INVALID_XML", signal.slug)
     self.assertIn("APPLICATION_FAIL", signal.tags)
 def test_invalid_xml(self, m):
     text = u"""<xml version=='1.0' encoding==UTF-8'?>
                  <!DOCTYPE note SYSTEM 'Note.dtd'>
                  <note>
                  <to>Tove</to>
                  <from>Jani</from>
                  <heading>Reminder</heading>
                  <body>Don't forget me this weekend!</body>
                  html>"""
     headers = {"Content-type": "application/xml"}
     m.register_uri(
         "GET",
         "http://example.com",
         text=textwrap.dedent(text),
         headers=headers)
     resp = requests.get("http://example.com")
     test = FakeTestObject(resp)
     signal = valid_content(test)
     self.assertEqual("INVALID_XML", signal.slug)
     self.assertIn("APPLICATION_FAIL", signal.tags)