Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
paths-ignore: ['docs/**']

push:
branches: ['main'] # Exercise 4 - add your branch name here
branches: ['main', 'exercise_2'] # Exercise 4 - add your branch name here
paths-ignore: ['docs/**']

concurrency:
Expand Down
4 changes: 3 additions & 1 deletion testing_workshop/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def get_metadata(self):
def get_iiif_image_url(self):
"""Returns the IIIF social media image of the page."""
# Exercise 2 - fill in the implementation here
pass
response = requests.get(self.url)
iiifSoup = BeautifulSoup(response.text)
return iiifSoup.head.find(property="og:image")["content"]


class NamedEntityDocument:
Expand Down
7 changes: 7 additions & 0 deletions testing_workshop/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ def test_get_metadata_code_500_raises_exception(self, page_url_invalid):
page.get_metadata()

# Exercise 2 - add test(s) for get_iiif_image_url() here
def test_get_iiif_image_url(self, page_url_valid):
page = DigitalLibraryPage(page_url_valid)
iiif_image_url = page.get_iiif_image_url()
assert (
iiif_image_url
== "https://images.lib.cam.ac.uk/iiif/MS-DAR-00100-000-00001.jp2/0,1885,2986,1568/1200,630/0/default.jpg"
)

# Exercise 5 - add test for expected exception FileNotFoundAtUrl for get_iiif_image_url() here

Expand Down