Skip to content

Commit

Permalink
make sure all reports we can parse can be written.
Browse files Browse the repository at this point in the history
WARNING: doesn't actually make any assertions they're written correctly,
just that they don't error anymore.
  • Loading branch information
Wooble committed Sep 20, 2019
1 parent 990088c commit 9735853
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
14 changes: 13 additions & 1 deletion pycounter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
u"DB1": u"Total Searches, Result Clicks and Record Views by Month and " u"Database",
u"DB2": u"Access Denied by Month, Database and Category",
u"JR1": u"Number of Successful Full-Text Article Requests by Month and " u"Journal",
u"JR1GOA": u"Number of Successful Gold Open Access Full-Text Article "
u"JR1 GOA": u"Number of Successful Gold Open Access Full-Text Article "
u"Requests by Month and Journal",
u"JR1a": u"Number of Successful Full-Text Article Requests from an "
u"Archive by Month and Journal",
Expand Down Expand Up @@ -106,6 +106,18 @@
u"Reporting Period HTML",
u"Reporting Period PDF",
),
"JR1 GOA": (
u"Journal",
u"Publisher",
u"Platform",
u"Journal DOI",
u"Proprietary Identifier",
u"Print ISSN",
u"Online ISSN",
u"Reporting Period Total",
u"Reporting Period HTML",
u"Reporting Period PDF",
),
"JR2": (
u"Journal",
u"Publisher",
Expand Down
25 changes: 25 additions & 0 deletions pycounter/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,28 @@ def br3_report():
def jr2_report():
"""Journal report 2 (turnaways)."""
return parsedata("C4JR2.csv")


@pytest.fixture(
params="""C4BR1.tsv
C4BR2.tsv
C4BR3.csv
C4DB1.tsv
C4DB1_split_year.tsv
C4DB2.tsv
C4JR1.csv
C4JR1_bad.csv
C4JR1big.csv
C4JR1GOA.csv
C4JR1mul.csv
C4JR1my.csv
C4JR2.csv
PR1.tsv
simpleBR1.csv
simpleJR1.csv
simpleJR1.tsv
""".split()
)
def all_reports(request):
"""All COUNTER 4 reports."""
return parsedata(request.param)
2 changes: 1 addition & 1 deletion pycounter/test/data/C4JR2.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"2011-01-01 to 2011-12-31"
"Date run:"
2012-02-21
Journal,Publisher,Platform,"Journal DOI","Proprietary Identifier","Print ISSN","Online ISSN","Access Denied Category","Reporting Period Total","Reporting Period HTML","Reporting Period PDF",Jan-2011,Feb-2011,Mar-2011,Apr-2011,May-2011,Jun-2011,Jul-2011,Aug-2011,Sep-2011,Oct-2011,Nov-2011,Dec-2011
Journal,Publisher,Platform,"Journal DOI","Proprietary Identifier","Print ISSN","Online ISSN","Access Denied Category","Reporting Period Total",Jan-2011,Feb-2011,Mar-2011,Apr-2011,May-2011,Jun-2011,Jul-2011,Aug-2011,Sep-2011,Oct-2011,Nov-2011,Dec-2011
"Total for all journals","Maximegalon University Press",MJO,,,,,16,0,16,2,1,0,0,0,5,1,1,0,5,1,0
"Abstracts of Working Papers in Economics","Maximegalon University Press",MJO,,,0951-0079,0951-0079,Access denied: concurrent/simultaneous user license limit exceeded,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0
"Acta Numerica","Maximegalon University Press",MJO,,,0962-4929,1474-0508,Access denied: concurrent/simultaneous user license limit exceeded,16,0,16,2,1,0,0,0,5,1,1,0,5,1,0
5 changes: 5 additions & 0 deletions pycounter/test/test_output_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ def test_totals_sparse_data(tmp_path):
assert book_line.startswith("Book 1")
numbers = [int(num) for num in book_line.split("\t")[-3:]]
assert numbers == [0, 3, 5], "check counts for book 1"


def test_roundtrippable(all_reports, tmp_path):
"""Test that all of our parsable reports can also be output."""
all_reports.write_tsv(tmp_path / "output.tsv")

0 comments on commit 9735853

Please sign in to comment.