Skip to content

Commit

Permalink
TT-1037: Create dummy pdf report for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikmonsen committed Sep 12, 2023
1 parent 69339e5 commit 31b96bd
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 23 deletions.
Binary file added test/resources/report.pdf
Binary file not shown.
Binary file removed test/resources/report1.pdf
Binary file not shown.
Binary file removed test/resources/report2.pdf
Binary file not shown.
8 changes: 4 additions & 4 deletions test/test_infopage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from metadata_extract.infopage import InfoPage
from metadata_extract.meteor_document import MeteorDocument

doc = MeteorDocument('test/resources/report2.pdf')
doc = MeteorDocument('test/resources/report.pdf')
infopagenr = InfoPage.find_page_number(doc.pages)


Expand All @@ -17,7 +17,7 @@ def test_infopagenr():


def test_find_title():
expected_title = 'Muligheter og utfordringer for økt karbonbinding i jordbruksjord'
expected_title = 'Metadataekstrahering – Muligheter og innsikt'
assert test_infopage.find_title() == expected_title


Expand All @@ -30,5 +30,5 @@ def test_find_isxn():

def test_find_authors():
authors = test_infopage.find_author()
assert set(authors) == {'Daniel Rasse', 'Inghild Økland', 'Teresa G. Bárcena',
'Hugh Riley', 'Vegard Martinsen', 'Ievina Sturite'}
assert set(authors) == {'Bjørnstjerne M. Bjørnson', 'Jacobine Camilla-Collett',
'Henrik J. Ibsen', 'Raymond McArthur', 'John O'}
56 changes: 37 additions & 19 deletions test/test_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@


meteor = Meteor()
results = meteor.run('test/resources/report1.pdf')
results = meteor.run('test/resources/report.pdf')


def test_year():
assert results['year'] == {
"value": 2021,
"value": 2023,
"origin": {
"type": "COPYRIGHT",
"pageNumber": 4
Expand All @@ -29,17 +29,16 @@ def test_language():

def test_title():
assert results['title'] == {
"value": "Barnefaglig kompetanse i utlendingsforvaltningen",
"value": "Metadataekstrahering – Muligheter og innsikt",
"origin": {
"type": "PDFINFO",
"pageNumber": 1
"type": "FRONT_PAGE"
}
}


def test_publisher():
assert results['publisher'] == {
"value": "Fafo",
"value": "Nasjonalbiblioteket",
"origin": {
"type": "COPYRIGHT",
"pageNumber": 4
Expand All @@ -59,24 +58,43 @@ def test_publication_type():
def test_authors():
expected_dict = [
{
"firstname": "Ragna",
"lastname": "Lillevik",
"firstname": "Bjørnstjerne M.",
"lastname": "Bjørnson",
"origin": {
"type": "INFO_PAGE",
"pageNumber": 2
}
},
{
"firstname": "Jacobine",
"lastname": "Camilla-Collett",
"origin": {
"type": "FRONT_PAGE"
"type": "INFO_PAGE",
"pageNumber": 2
}
},
{
"firstname": "Lene Christin",
"lastname": "Holum",
"firstname": "Henrik J.",
"lastname": "Ibsen",
"origin": {
"type": "FRONT_PAGE"
"type": "INFO_PAGE",
"pageNumber": 2
}
},
{
"firstname": "Nerina",
"lastname": "Weiss",
"firstname": "Raymond",
"lastname": "McArthur",
"origin": {
"type": "FRONT_PAGE"
"type": "INFO_PAGE",
"pageNumber": 2
}
},
{
"firstname": "John",
"lastname": "O",
"origin": {
"type": "INFO_PAGE",
"pageNumber": 2
}
}
]
Expand All @@ -94,19 +112,19 @@ def test_authors():

def test_isbn():
assert results['isbn'] == {
"value": "978-82-324-0629-6",
"value": "978-82-17-02298-5",
"origin": {
"type": "PAGE",
"pageNumber": 4
"pageNumber": 2
}
}


def test_issn():
assert results['issn'] == {
"value": "2387-6859",
"value": "2464-1162",
"origin": {
"type": "PAGE",
"pageNumber": 4
"pageNumber": 2
}
}

0 comments on commit 31b96bd

Please sign in to comment.