Skip to content

Commit

Permalink
Elsevier Parser: remove date_published simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
ErnestaP committed Jul 22, 2024
1 parent d11f31b commit cd97ba1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions dags/elsevier/metadata_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ def __init__(self, file_path):
CustomExtractor(
destination="date_published",
extraction_function=self._get_published_date,
required=True,
),
CustomExtractor(
destination="journal_year",
extraction_function=self._get_journal_year,
required=True,
),
CustomExtractor(
destination="collections",
Expand Down Expand Up @@ -88,14 +86,11 @@ def _get_published_date(self, article):
field_name="published_date",
dois=self.dois,
)
if not date:
self.published_date = datetime.now().strftime("%Y-%m-%d")
self.year = datetime.now().strftime("%Y")
if date:
date = datetime.fromisoformat(date[:-1])
self.published_date = date.strftime("%Y-%m-%d")
self.year = date.strftime("%Y")
return self.published_date
date = datetime.fromisoformat(date[:-1])
self.published_date = date.strftime("%Y-%m-%d")
self.year = date.strftime("%Y")
return self.published_date

def _get_journal_year(self, article):
return self.year
Expand Down
4 changes: 2 additions & 2 deletions tests/units/elsevier/test_metadata_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def parsed_articles(parser, article):
id="test_publication_info",
),
param(
["2023-11-02", "2023-11-02", "2023-02-04", "2023-11-02"],
["", "", "2023-02-04", ""],
"date_published",
id="test_published_date",
),
Expand Down Expand Up @@ -150,7 +150,7 @@ def parsed_articles(parser, article):
@freeze_time("2023-11-02")
def test_elsevier_dataset_parsing(parsed_articles, expected, key):
for (parsed_article, expected_article) in zip(parsed_articles, expected):
assert expected_article == parsed_article[key]
assert expected_article == parsed_article.get(key, "")


@fixture
Expand Down

0 comments on commit cd97ba1

Please sign in to comment.