Skip to content

Commit

Permalink
Reorganize template scraper method order, placing abstract methods ne…
Browse files Browse the repository at this point in the history
…arest the top of the class definition
  • Loading branch information
jayaddison committed Oct 27, 2022
1 parent 1c7f61f commit f502afa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions recipe_scrapers/_abstract.py
Expand Up @@ -156,6 +156,7 @@ def ratings(self):
raise NotImplementedError("This should be implemented.")

def author(self):
# question: should we make this a required field (abstractmethod)?
raise NotImplementedError("This should be implemented.")

def cuisine(self):
Expand Down
19 changes: 10 additions & 9 deletions templates/scraper.py
Expand Up @@ -8,21 +8,12 @@ class Template(AbstractScraper):
def host(cls):
return "example.com"

def author(self):
return self.schema.author()

def title(self):
return self.schema.title()

def category(self):
return self.schema.category()

def total_time(self):
return self.schema.total_time()

def yields(self):
return self.schema.yields()

def image(self):
return self.schema.image()

Expand All @@ -32,6 +23,16 @@ def ingredients(self):
def instructions(self):
return self.schema.instructions()

def author(self):
# question: should we make this a required field?
return self.schema.author()

def category(self):
return self.schema.category()

def yields(self):
return self.schema.yields()

def ratings(self):
return self.schema.ratings()

Expand Down
19 changes: 10 additions & 9 deletions templates/test_scraper.py
Expand Up @@ -11,21 +11,12 @@ class TestTemplateScraper(ScraperTest):
def test_host(self):
self.assertEqual("example.com", self.harvester_class.host())

def test_author(self):
self.assertEqual(None, self.harvester_class.author())

def test_title(self):
self.assertEqual(None, self.harvester_class.title())

def test_category(self):
self.assertEqual(None, self.harvester_class.category())

def test_total_time(self):
self.assertEqual(None, self.harvester_class.total_time())

def test_yields(self):
self.assertEqual(None, self.harvester_class.yields())

def test_image(self):
self.assertEqual(None, self.harvester_class.image())

Expand All @@ -35,6 +26,16 @@ def test_ingredients(self):
def test_instructions(self):
self.assertEqual(None, self.harvester_class.instructions())

def test_author(self):
# should we make this a required field?
self.assertEqual(None, self.harvester_class.author())

def test_category(self):
self.assertEqual(None, self.harvester_class.category())

def test_yields(self):
self.assertEqual(None, self.harvester_class.yields())

def test_ratings(self):
self.assertEqual(None, self.harvester_class.ratings())

Expand Down

0 comments on commit f502afa

Please sign in to comment.