summaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-11-19 20:57:19 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-11-19 20:57:19 -0800
commit65bdebea35f2ab3c9c8b0f8a8b0a9a577a36bee2 (patch)
tree145321b85a9af61f0a93112831724717faced5e0 /python/tests
parent337416e965457c07dab44864f6dabb516fdf6a03 (diff)
downloadfatcat-65bdebea35f2ab3c9c8b0f8a8b0a9a577a36bee2.tar.gz
fatcat-65bdebea35f2ab3c9c8b0f8a8b0a9a577a36bee2.zip
better DOI registrar harvesters
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/harvest_state.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/python/tests/harvest_state.py b/python/tests/harvest_state.py
new file mode 100644
index 00000000..85cd2c99
--- /dev/null
+++ b/python/tests/harvest_state.py
@@ -0,0 +1,40 @@
+
+import json
+import pytest
+import datetime
+from fatcat_tools.harvest import *
+
+
+def test_harvest_state():
+
+ today = datetime.datetime.utcnow().date()
+
+ hs = HarvestState(catchup_days=5)
+ assert max(hs.to_process) < today
+ assert len(hs.to_process) is 5
+
+ for d in list(hs.to_process):
+ hs.complete(d)
+
+ assert hs.next() is None
+
+ hs = HarvestState(
+ start_date=datetime.date(2000,1,1),
+ end_date=datetime.date(2000,1,3),
+ )
+ assert len(hs.to_process) is 3
+ hs = HarvestState(
+ start_date=datetime.date(2000,1,29),
+ end_date=datetime.date(2000,2,2),
+ )
+ assert len(hs.to_process) is 5
+
+ hs = HarvestState(catchup_days=0)
+ assert hs.next() is None
+ hs.enqueue_period(
+ start_date=datetime.date(2000,1,1),
+ end_date=datetime.date(2000,1,3),
+ )
+ assert len(hs.to_process) is 3
+ hs.update('{"completed-date": "2000-01-02"}')
+ assert len(hs.to_process) is 2