You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the new dynamic implementation of sets, the old add_record and remove_records do not work. They can be implemented but would require to do update the search_pattern.
defadd_record(self, record):
"""Add a record to the OAISet. :param record: Record to be added. :type record: `invenio_records.api.Record` or derivative. """record.setdefault('_oai', {}).setdefault('sets', [])
assertnotself.has_record(record)
record['_oai']['sets'].append(self.spec)
defremove_record(self, record):
"""Remove a record from the OAISet. :param record: Record to be removed. :type record: `invenio_records.api.Record` or derivative. """assertself.has_record(record)
record['_oai']['sets'] = [
sforsinrecord['_oai']['sets'] ifs!=self.spec]
Old tests:
deftest_oaiset_add_remove_record(app):
"""Test the API method for manual record adding."""withapp.app_context():
oaiset1=OAISet(spec='abc')
rec1=Record.create({'title_statement': {'title': 'Test1'}})
rec1.commit()
# Adding a record to an OAIset should change the record's updated datedt1=rec1.updatedassertnotoaiset1.has_record(rec1)
oaiset1.add_record(rec1)
assert'abc'inrec1['_oai']['sets']
assertoaiset1.has_record(rec1)
rec1.commit()
dt2=rec1.updatedassertdt2>dt1oaiset1.remove_record(rec1)
rec1.commit()
dt3=rec1.updatedassert'abc'notinrec1['_oai']['sets']
assertnotoaiset1.has_record(rec1)
assertdt3>dt2
The text was updated successfully, but these errors were encountered:
With the new dynamic implementation of sets, the old
add_record
andremove_records
do not work. They can be implemented but would require to do update thesearch_pattern
.Old tests:
The text was updated successfully, but these errors were encountered: