Example #1
0
 def test_convert_url(self):
     converter = URLConverter()
     self.assertEqual(
         converter.convert_url("http://dummy.jpg", "styles/"),
         "http://dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("https://dummy.jpg", "styles/"),
         "https://dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("/dummy.jpg", "styles/"),
         "/dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("data:abc", "styles/"),
         "data:abc"
     )
     self.assertEqual(
         converter.convert_url("dummy.jpg", "styles/"),
         "/static/styles/dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("./dummy.jpg", "styles/"),
         "/static/styles/dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("../images/dummy.jpg", "styles/"),
         "/static/images/dummy.jpg"
     )
Example #2
0
def test_convert(monkeypatch):
    converter = URLConverter()

    monkeypatch.setattr("static_precompiler.utils.URLConverter.convert_url", lambda self, *args: "spam.jpg")
    assert converter.convert("p {\n  background-url: url(ham.jpg);\n}", "") == "p {\n  background-url: url('spam.jpg');\n}"
    assert converter.convert('p {\n  background-url: url("ham.jpg");\n}', "") == "p {\n  background-url: url('spam.jpg');\n}"
    assert converter.convert("p {\n  background-url: url('ham.jpg');\n}", "") == "p {\n  background-url: url('spam.jpg');\n}"
    assert converter.convert(""".external_link:first-child:before {
  content: "Zobacz także:";
  background: url(картинка.png); }
""", "") == """.external_link:first-child:before {
 def test_convert_url(self):
     converter = URLConverter()
     self.assertEqual(
         converter.convert_url("http://dummy.jpg", "styles/"),
         "http://dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("https://dummy.jpg", "styles/"),
         "https://dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("/dummy.jpg", "styles/"),
         "/dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("data:abc", "styles/"),
         "data:abc"
     )
     self.assertEqual(
         converter.convert_url("dummy.jpg", "styles/"),
         "/static/styles/dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("./dummy.jpg", "styles/"),
         "/static/styles/dummy.jpg"
     )
     self.assertEqual(
         converter.convert_url("../images/dummy.jpg", "styles/"),
         "/static/images/dummy.jpg"
     )
def test_convert_url():
    converter = URLConverter()

    assert converter.convert_url("http://dummy.jpg", "styles/") == "http://dummy.jpg"
    assert converter.convert_url("https://dummy.jpg", "styles/") == "https://dummy.jpg"
    assert converter.convert_url("/dummy.jpg", "styles/") == "/dummy.jpg"
    assert converter.convert_url("data:abc", "styles/") == "data:abc"
    assert converter.convert_url("dummy.jpg", "styles/") == "/static/styles/dummy.jpg"
    assert converter.convert_url("./dummy.jpg", "styles/") == "/static/styles/dummy.jpg"
    assert converter.convert_url("../images/dummy.jpg", "styles/") == "/static/images/dummy.jpg"
Example #5
0
def test_convert_url():
    converter = URLConverter()

    assert converter.convert_url("http://dummy.jpg",
                                 "styles/") == "http://dummy.jpg"
    assert converter.convert_url("https://dummy.jpg",
                                 "styles/") == "https://dummy.jpg"
    assert converter.convert_url("/dummy.jpg", "styles/") == "/dummy.jpg"
    assert converter.convert_url("data:abc", "styles/") == "data:abc"
    assert converter.convert_url("dummy.jpg",
                                 "styles/") == "/static/styles/dummy.jpg"
    assert converter.convert_url("./dummy.jpg",
                                 "styles/") == "/static/styles/dummy.jpg"
    assert converter.convert_url("../images/dummy.jpg",
                                 "styles/") == "/static/images/dummy.jpg"
Example #6
0
    def test_convert(self):
        converter = URLConverter()
        converter.convert_url = MagicMock(return_value="spam.jpg")
        self.assertEqual(
            converter.convert("p {\n  background-url: url(ham.jpg);\n}", ""),
            "p {\n  background-url: url('spam.jpg');\n}")
        self.assertEqual(
            converter.convert('p {\n  background-url: url("ham.jpg");\n}', ""),
            "p {\n  background-url: url('spam.jpg');\n}")
        self.assertEqual(
            converter.convert("p {\n  background-url: url('ham.jpg');\n}", ""),
            "p {\n  background-url: url('spam.jpg');\n}")
        self.assertEqual(
            converter.convert(
                """.external_link:first-child:before {
  content: "Zobacz także:";
  background: url(картинка.png); }
""", ""), """.external_link:first-child:before {
  content: "Zobacz także:";
  background: url('spam.jpg'); }
""")
Example #7
0
def test_convert(monkeypatch):
    converter = URLConverter()

    monkeypatch.setattr("static_precompiler.utils.URLConverter.convert_url",
                        lambda self, *args: "spam.jpg")
    assert (converter.convert(
        "p {\n  background-url: url(ham.jpg);\n}",
        "") == "p {\n  background-url: url('spam.jpg');\n}")
    assert (converter.convert(
        'p {\n  background-url: url("ham.jpg");\n}',
        "") == "p {\n  background-url: url('spam.jpg');\n}")
    assert (converter.convert(
        "p {\n  background-url: url('ham.jpg');\n}",
        "") == "p {\n  background-url: url('spam.jpg');\n}")
    assert converter.convert(
        """.external_link:first-child:before {
  content: "Zobacz także:";
  background: url(картинка.png); }
""", "") == """.external_link:first-child:before {
    def test_convert(self):
        converter = URLConverter()
        converter.convert_url = MagicMock(return_value="spam.jpg")
        self.assertEqual(
            converter.convert("p {\n  background-url: url(ham.jpg);\n}", ""),
            "p {\n  background-url: url('spam.jpg');\n}"
        )
        self.assertEqual(
            converter.convert('p {\n  background-url: url("ham.jpg");\n}', ""),
            "p {\n  background-url: url('spam.jpg');\n}"
        )
        self.assertEqual(
            converter.convert("p {\n  background-url: url('ham.jpg');\n}", ""),
            "p {\n  background-url: url('spam.jpg');\n}"
        )
        self.assertEqual(
            converter.convert(""".external_link:first-child:before {
  content: "Zobacz także:";
  background: url(картинка.png); }
""", ""),
            """.external_link:first-child:before {
  content: "Zobacz także:";
  background: url('spam.jpg'); }
""")