Skip to content

Commit

Permalink
seminars: add literature records field
Browse files Browse the repository at this point in the history
* INSPIR-3571
* Locked pytest-cov because it requires a higher version of pytest
  • Loading branch information
monaawi committed Jun 15, 2020
1 parent 94f6db9 commit a0039d2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
14 changes: 14 additions & 0 deletions inspire_schemas/builders/seminars.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ def add_speaker(self, name=None, record=None, affiliations=None, ids=None, curat
curated_relation=curated_relation,
)

@filter_empty_parameters
def add_literature_record(self, record, curated_relation=None):
"""
Args:
record (dict): dictionary with ``$ref`` pointing to proper record.
If string, then will be converted to proper dict.
curated_relation (bool): mark if relation is curated [NOT REQUIRED]
"""
self._append_to(
'literature_records',
record=record,
curated_relation=curated_relation,
)

@filter_empty_parameters
def add_join_url(self, value, description=None):
"""Add url dict to ``urls`` list.
Expand Down
15 changes: 15 additions & 0 deletions inspire_schemas/records/seminars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,21 @@ properties:
title: List of speakers
type: array
uniqueItems: true
literature_records:
items:
additionalProperties: false
properties:
curated_relation:
type: boolean
record:
$ref: elements/json_reference.json
required:
- record
type: object
minItems: 1
title: List of literature records related to the seminar
type: array
uniqueItems: true
start_datetime:
format: date-time
minLength: 1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _generate_json_schemas():
'coverage',
'isort~=4.0,>=4.3.0',
'pytest-cache',
'pytest-cov~=2.0,>=2.6.1',
'pytest-cov==2.6.1',
'pytest~=3.0,>=3.6.0',
'pytest-pep8',
'mock',
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/test_seminar_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,25 @@ def test_add_speaker():
)
builder.add_speaker(name='some guy')
assert builder.record['speakers'] == expected


def test_add_literature_record():
expected = [
{
'record': {'$ref': 'http://literature/1'}
},
{
'record': {'$ref': 'http://literature/another'},
'curated_relation': True
},
]

builder = SeminarBuilder()
builder.add_literature_record(
record={'$ref': 'http://literature/1'}
)
builder.add_literature_record(
record={'$ref': 'http://literature/another'},
curated_relation=True
)
assert builder.record['literature_records'] == expected

0 comments on commit a0039d2

Please sign in to comment.