Skip to content

Commit

Permalink
Merge pull request #26 from ammirate/bump_to_schema_49
Browse files Browse the repository at this point in the history
global: bump inspire-schemas to version ~49.0
  • Loading branch information
ammirate authored Sep 28, 2017
2 parents 70552a8 + 17775b9 commit 9f16963
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
10 changes: 4 additions & 6 deletions inspire_json_merger/merger_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ class ArxivToArxivOperations(MergerConfigurationOperations):
'references.reference.report_numbers': UnifierOps.KEEP_UPDATE_AND_HEAD_ENTITIES_HEAD_FIRST,
'references.reference.urls': UnifierOps.KEEP_ONLY_UPDATE_ENTITIES,
'report_numbers': UnifierOps.KEEP_ONLY_UPDATE_ENTITIES,
'special_collections': UnifierOps.KEEP_ONLY_HEAD_ENTITIES,
'texkeys': UnifierOps.KEEP_ONLY_HEAD_ENTITIES,
'thesis_info.institutions': UnifierOps.KEEP_ONLY_UPDATE_ENTITIES,
'title_translations': UnifierOps.KEEP_ONLY_HEAD_ENTITIES,
Expand All @@ -169,6 +168,8 @@ class ArxivToArxivOperations(MergerConfigurationOperations):
'authors.uuid': DictMergerOps.FALLBACK_KEEP_UPDATE,
'book_series': DictMergerOps.FALLBACK_KEEP_HEAD,
'control_number': DictMergerOps.FALLBACK_KEEP_HEAD,
'curated': DictMergerOps.FALLBACK_KEEP_HEAD,
'curated': DictMergerOps.FALLBACK_KEEP_HEAD,
'deleted': DictMergerOps.FALLBACK_KEEP_HEAD,
'deleted_records': DictMergerOps.FALLBACK_KEEP_HEAD,
'funding_info': DictMergerOps.FALLBACK_KEEP_HEAD,
Expand All @@ -192,7 +193,6 @@ class ArxivToArxivOperations(MergerConfigurationOperations):
'references.reference.title': DictMergerOps.FALLBACK_KEEP_UPDATE,
'references.reference.urls': DictMergerOps.FALLBACK_KEEP_UPDATE,
'self': DictMergerOps.FALLBACK_KEEP_HEAD,
'special_collections': DictMergerOps.FALLBACK_KEEP_HEAD,
'succeeding_entry': DictMergerOps.FALLBACK_KEEP_HEAD,
'texkeys': DictMergerOps.FALLBACK_KEEP_HEAD,
'thesis_info.institutions': DictMergerOps.FALLBACK_KEEP_HEAD,
Expand Down Expand Up @@ -251,7 +251,6 @@ class PublisherToArxivOperations(MergerConfigurationOperations):
'references.reference.report_numbers': UnifierOps.KEEP_UPDATE_AND_HEAD_ENTITIES_HEAD_FIRST,
'references.reference.urls': UnifierOps.KEEP_ONLY_UPDATE_ENTITIES,
'report_numbers': UnifierOps.KEEP_UPDATE_ENTITIES_CONFLICT_ON_HEAD_DELETE,
'special_collections': UnifierOps.KEEP_ONLY_HEAD_ENTITIES,
'texkeys': UnifierOps.KEEP_ONLY_HEAD_ENTITIES,
'thesis_info.institutions': UnifierOps.KEEP_ONLY_UPDATE_ENTITIES,
'title_translations': UnifierOps.KEEP_UPDATE_AND_HEAD_ENTITIES_UPDATE_FIRST,
Expand Down Expand Up @@ -286,6 +285,7 @@ class PublisherToArxivOperations(MergerConfigurationOperations):
'copyright': DictMergerOps.FALLBACK_KEEP_UPDATE,
'core': DictMergerOps.FALLBACK_KEEP_UPDATE,
'corporate_author': DictMergerOps.FALLBACK_KEEP_UPDATE,
'curated': DictMergerOps.FALLBACK_KEEP_HEAD,
'deleted': DictMergerOps.FALLBACK_KEEP_HEAD,
'deleted_records': DictMergerOps.FALLBACK_KEEP_HEAD,
'editions': DictMergerOps.FALLBACK_KEEP_HEAD,
Expand Down Expand Up @@ -313,7 +313,6 @@ class PublisherToArxivOperations(MergerConfigurationOperations):
'references.reference.urls': DictMergerOps.FALLBACK_KEEP_UPDATE,
'report_numbers': DictMergerOps.FALLBACK_KEEP_HEAD,
'self': DictMergerOps.FALLBACK_KEEP_HEAD,
'special_collections': DictMergerOps.FALLBACK_KEEP_HEAD,
'succeeding_entry': DictMergerOps.FALLBACK_KEEP_HEAD,
'texkeys': DictMergerOps.FALLBACK_KEEP_HEAD,
'thesis_info.institutions': DictMergerOps.FALLBACK_KEEP_UPDATE,
Expand Down Expand Up @@ -377,7 +376,6 @@ class PublisherToPublisherOperations(MergerConfigurationOperations):
'references.reference.report_numbers': UnifierOps.KEEP_UPDATE_AND_HEAD_ENTITIES_HEAD_FIRST,
'references.reference.urls': UnifierOps.KEEP_ONLY_UPDATE_ENTITIES,
'report_numbers': UnifierOps.KEEP_ONLY_UPDATE_ENTITIES,
'special_collections': UnifierOps.KEEP_ONLY_HEAD_ENTITIES,
'texkeys': UnifierOps.KEEP_ONLY_HEAD_ENTITIES,
'thesis_info.institutions': UnifierOps.KEEP_ONLY_UPDATE_ENTITIES,
'title_translations': UnifierOps.KEEP_ONLY_HEAD_ENTITIES,
Expand All @@ -404,6 +402,7 @@ class PublisherToPublisherOperations(MergerConfigurationOperations):
'authors.uuid': DictMergerOps.FALLBACK_KEEP_UPDATE,
'book_series': DictMergerOps.FALLBACK_KEEP_HEAD,
'control_number': DictMergerOps.FALLBACK_KEEP_HEAD,
'curated': DictMergerOps.FALLBACK_KEEP_HEAD,
'deleted': DictMergerOps.FALLBACK_KEEP_HEAD,
'deleted_records': DictMergerOps.FALLBACK_KEEP_HEAD,
'funding_info': DictMergerOps.FALLBACK_KEEP_HEAD,
Expand All @@ -427,7 +426,6 @@ class PublisherToPublisherOperations(MergerConfigurationOperations):
'references.reference.title': DictMergerOps.FALLBACK_KEEP_UPDATE,
'references.reference.urls': DictMergerOps.FALLBACK_KEEP_UPDATE,
'self': DictMergerOps.FALLBACK_KEEP_HEAD,
'special_collections': DictMergerOps.FALLBACK_KEEP_HEAD,
'succeeding_entry': DictMergerOps.FALLBACK_KEEP_HEAD,
'texkeys': DictMergerOps.FALLBACK_KEEP_HEAD,
'thesis_info.institutions': DictMergerOps.FALLBACK_KEEP_HEAD,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
'munkres>=1.0.7',
'Unidecode>=0.4.19',
'autosemver',
'inspire-schemas~=48.0,>=48.0.0',
'inspire-schemas~=49.0,>=49.0.0',
]

packages = find_packages()
Expand Down
50 changes: 27 additions & 23 deletions tests/unit/test_merger_arxiv2arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def test_merging_schema_field():

@cover('_collections')
def test_merging_collections_field():
root = {'_collections': ['Literature']}
head = {'_collections': ['Literature', 'Conference']}
update = {'_collections': ['Literature', 'Paper']}
root = {'_collections': ['BABAR Analysis Documents']}
head = {'_collections': ['BABAR Analysis Documents', 'CDF Internal Notes']}
update = {'_collections': ['BABAR Analysis Documents', 'CDF Notes']}

expected_merged = head
expected_conflict = None
Expand Down Expand Up @@ -2595,26 +2595,6 @@ def test_merging_self_field():
assert conflict == expected_conflict


@cover('special_collections')
def test_merging_special_collections_field():
root = {'special_collections': ['CDF-INTERNAL-NOTE', 'CDF-NOTE']}
head = {'special_collections': ['CDF-INTERNAL-NOTE']}
update = {'special_collections': []}

expected_merged = head
expected_conflict = None

root, head, update, expected_merged = add_arxiv_source(root, head, update, expected_merged)
merged, conflict = inspire_json_merge(root, head, update)

expected_conflict = sort_conflicts(expected_conflict)

merged = add_arxiv_source(merged)
assert merged == expected_merged
assert conflict == expected_conflict
validate_subschema(merged)


@cover('texkeys')
def test_merging_texkeys_field():
root = {'texkeys': ['Kotwal:2016']}
Expand Down Expand Up @@ -3765,9 +3745,33 @@ def test_related_records_field():
validate_subschema(merged)


@cover('curated')
def test_curated():
root = {}
head = {
'curated': True
}
# will never come from updates
update = {}

expected_merged = head
expected_conflict = None

root, head, update, expected_merged = add_arxiv_source(root, head, update, expected_merged)
merged, conflict = inspire_json_merge(root, head, update)

expected_conflict = sort_conflicts(expected_conflict)

merged = add_arxiv_source(merged)
assert merged == expected_merged
assert conflict == expected_conflict
validate_subschema(merged)


def test_schema_keys_coverage():
# This test check that every key in the schema has been covered by at
# least one test.
# IMPORTANT: this test depends on the others, so keep it as the last
schema = load_schema('hep')
key_list = schema['properties'].keys()
missing = []
Expand Down

0 comments on commit 9f16963

Please sign in to comment.