Skip to content

Commit

Permalink
test(urlbuilder): add more testcases to test urlbuilder with srcset
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshkrris committed Oct 7, 2022
1 parent 51f15e2 commit de9dee6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_srcset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
DOMAIN = "testing.imgix.net"
TOKEN = "MYT0KEN"
JPG_PATH = "image.jpg"
JPG_PATH_WITH_SPACE = 'image 123.jpg'


def extract_descriptors(srcset=""):
Expand Down Expand Up @@ -132,6 +133,22 @@ def test_create_srcset_100_to_108():
assert expected == actual


def test_create_srcset_with_widths_and_disable_path_encoding_true():
ub = imgix.UrlBuilder(DOMAIN, include_library_param=False, disable_path_encoding=True)
actual = ub.create_srcset(JPG_PATH_WITH_SPACE, widths=[100])
expected = "https://testing.imgix.net/image 123.jpg?w=100 100w"

assert(expected == actual)


def test_create_srcset_start_equals_stop_with_disable_path_encoding_true():
ub = imgix.UrlBuilder(DOMAIN, include_library_param=False, disable_path_encoding=True)
actual = ub.create_srcset(JPG_PATH_WITH_SPACE, start=713, stop=713)
expected = "https://testing.imgix.net/image 123.jpg?w=713 713w"

assert(expected == actual)


def test_given_width_srcset_is_DPR():
srcset = _default_srcset({"w": 100})
device_pixel_ratio = 1
Expand Down

0 comments on commit de9dee6

Please sign in to comment.