Example #1
0
 def test_two_headers(self):
     expected = TextList([
         ColorText("Header: Value", bg_color="blue"),
         ColorText("Host: github.com", bg_color="blue")
     ])
     self.assertEqual(
         expected.__dict__,
         Header([("Header", "Value"), ("Host", "github.com")]).__dict__)
Example #2
0
 def test_simple_response(self):
     response = HttpResponse(headers=[("Content-Type", "application/xml")])
     expected = TextList([
         ColorText("Response Headers:", fg_color="blue", attrs=["bold"]),
         Header([("Content-Type", "application/xml")])
     ])
     self.assertEqual(expected.__dict__, Response(response).__dict__)
Example #3
0
 def test_simple_request(self):
     request = HttpRequest(headers=[("Host", "github.com")])
     expected = TextList([
         ColorText("Request Headers:", fg_color="blue", attrs=["bold"]),
         Header([("Host", "github.com")])
     ])
     self.assertEqual(expected.__dict__, Request(request).__dict__)
Example #4
0
 def test_status_error(self):
     self.assertEqual(
         TextList([
             ColorText(400, fg_color="red", attrs=["bold"]), "GET",
             "http://github.com/index"
         ],
                  delimiter=" ").__dict__,
         StatusText(400, "GET", "http://github.com", "/index").__dict__)
Example #5
0
 def test_fg_and_bg_and_bold(self):
     self.assertEqual(
         fg("blue") + bg("blue") + attr("bold") + "fg bg test" +
         attr("reset"),
         str(
             ColorText("fg bg test",
                       fg_color="blue",
                       bg_color="blue",
                       attrs=["bold"])))
Example #6
0
 def test_comma_delimiter(self):
     self.assertEqual(
         "test,123",
         str(TextList([ColorText("test"), ColorText(123)], delimiter=",")))
Example #7
0
 def test_default_delimiter(self):
     self.assertEqual("test\n123",
                      str(TextList([ColorText("test"),
                                    ColorText(123)])))
Example #8
0
 def test_bold_and_underlined(self):
     self.assertEqual(
         attr("bold") + attr("underlined") + "bold underlined test" +
         attr("reset"),
         str(ColorText("bold underlined test", attrs=["bold",
                                                      "underlined"])))
Example #9
0
 def test_bold(self):
     self.assertEqual(
         attr("bold") + "bold test" + attr("reset"),
         str(ColorText("bold test", attrs=["bold"])))
Example #10
0
 def test_bg(self):
     self.assertEqual(
         bg("blue") + "bg test" + attr("reset"),
         str(ColorText("bg test", bg_color="blue")))
Example #11
0
 def test_fg(self):
     self.assertEqual(
         fg("blue") + "fg test" + attr("reset"),
         str(ColorText("fg test", fg_color="blue")))
Example #12
0
 def test_clear_text(self):
     self.assertEqual("clear text", str(ColorText("clear text")))