summaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
authorbnewbold <bnewbold@archive.org>2020-07-24 02:56:13 +0000
committerbnewbold <bnewbold@archive.org>2020-07-24 02:56:13 +0000
commit2170e5ff46dfb2bba9bf26196de3c3774c16cd4a (patch)
treee78de45cbca526dfacf7ae9ada31152a790fa0a4 /python/tests
parent6a87b3d2e1b315d35ccaa13457571d73afaf5e6b (diff)
parent3e5799e0bb3f0eb7b9f5d690692757cfbf400412 (diff)
downloadfatcat-2170e5ff46dfb2bba9bf26196de3c3774c16cd4a.tar.gz
fatcat-2170e5ff46dfb2bba9bf26196de3c3774c16cd4a.zip
Merge branch 'bnewbold-preservation-year-offset' into 'master'
preservation year offset See merge request webgroup/fatcat!67
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/transform_elasticsearch.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/python/tests/transform_elasticsearch.py b/python/tests/transform_elasticsearch.py
index f791562c..0d96e139 100644
--- a/python/tests/transform_elasticsearch.py
+++ b/python/tests/transform_elasticsearch.py
@@ -1,5 +1,6 @@
import json
+import datetime
from fatcat_tools import *
from fatcat_openapi_client import *
@@ -137,3 +138,48 @@ def test_elasticsearch_changelog_transform(matched_importer):
assert es['new_releases'] == 0
assert es['updated'] == 0
assert es['deleted'] == 0
+
+def test_elasticsearch_release_kbart_year():
+ this_year = datetime.date.today().year
+ r = ReleaseEntity(
+ title="something",
+ release_year=this_year,
+ license_slug="CC-BY-NC",
+ ext_ids=ReleaseExtIds(),
+ refs=[
+ ReleaseRef(),
+ ReleaseRef(target_release_id="iznnn644szdwva7khyxqzc73bi"),
+ ],
+ )
+ r.state = 'active'
+ r.container = ContainerEntity(
+ name="dummy journal",
+ extra={
+ "kbart": {
+ "lockss": {
+ "year_spans": [[1900, this_year - 2]],
+ },
+ },
+ },
+ )
+ es = release_to_elasticsearch(r)
+ assert es['release_year'] == this_year
+ assert es['in_ia'] == False
+ assert es['in_kbart'] == False
+ assert es['preservation'] == "none"
+
+ r.container = ContainerEntity(
+ name="dummy journal",
+ extra={
+ "kbart": {
+ "lockss": {
+ "year_spans": [[1900, this_year - 1]],
+ },
+ },
+ },
+ )
+ es = release_to_elasticsearch(r)
+ assert es['release_year'] == this_year
+ assert es['in_ia'] == False
+ assert es['in_kbart'] == True
+ assert es['preservation'] == "dark"