Skip to content

Commit

Permalink
Fix generation of Via /video/youtube URLs
Browse files Browse the repository at this point in the history
We changed Via's `/video` endpoint to `/video/youtube`:

hypothesis/via#980

Update h-vialib's Via URL generation to generate `/video/youtube` URLs
instead of just `/video` ones.
  • Loading branch information
seanh committed Jun 13, 2023
1 parent e3d518e commit 4486ea7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/h_vialib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class ContentType(str, Enum):
PDF = "pdf"
HTML = "html"
VIDEO = "video"
YOUTUBE = "youtube"


class ViaDoc:
Expand Down Expand Up @@ -106,7 +106,7 @@ def _url_for(self, doc, query):
# Optimisation to skip routing for documents we know the type of
content_type_paths = {
ContentType.PDF: "/pdf",
ContentType.VIDEO: "/video",
ContentType.YOUTUBE: "/video/youtube",
}
path = content_type_paths.get(doc.content_type, "/route")

Expand Down
7 changes: 6 additions & 1 deletion tests/unit/h_vialib/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ class TestViaClient:
}

@pytest.mark.parametrize(
"content_type,path", ((None, "/route"), ("pdf", "/pdf"), ("video", "/video"))
"content_type,path",
(
(None, "/route"),
(ContentType.PDF, "/pdf"),
(ContentType.YOUTUBE, "/video/youtube"),
),
)
def test_url_for(self, client, content_type, path):
url = "http://example.com&a=1&a=2"
Expand Down

0 comments on commit 4486ea7

Please sign in to comment.