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__)
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__)
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__)
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__)
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"])))
def test_comma_delimiter(self): self.assertEqual( "test,123", str(TextList([ColorText("test"), ColorText(123)], delimiter=",")))
def test_default_delimiter(self): self.assertEqual("test\n123", str(TextList([ColorText("test"), ColorText(123)])))
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"])))
def test_bold(self): self.assertEqual( attr("bold") + "bold test" + attr("reset"), str(ColorText("bold test", attrs=["bold"])))
def test_bg(self): self.assertEqual( bg("blue") + "bg test" + attr("reset"), str(ColorText("bg test", bg_color="blue")))
def test_fg(self): self.assertEqual( fg("blue") + "fg test" + attr("reset"), str(ColorText("fg test", fg_color="blue")))
def test_clear_text(self): self.assertEqual("clear text", str(ColorText("clear text")))