diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fed6f24..a3c2605 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/testing_workshop/functions.py b/testing_workshop/functions.py index 8c9a3a9..863847b 100644 --- a/testing_workshop/functions.py +++ b/testing_workshop/functions.py @@ -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: diff --git a/testing_workshop/tests/test_functions.py b/testing_workshop/tests/test_functions.py index 9cf8177..e1afffc 100644 --- a/testing_workshop/tests/test_functions.py +++ b/testing_workshop/tests/test_functions.py @@ -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