def test_references_validator_does_nothing_on_empty_list(): json_dict = { 'references': [], } references_validator(None, json_dict) assert json_dict['references'] == []
def test_references_validator_does_nothing_on_numerical_recids(): json_dict = { 'references': [ {'recid': 123}, {'recid': 456}, ], } references_validator(None, json_dict) assert json_dict['references'] == [ {'recid': 123}, {'recid': 456}, ]
def test_references_validator_removes_and_warns_on_non_numerical_recids(warning): json_dict = { 'control_number': '123', 'references': [ {'recid': 'foo'}, {'recid': 456}, ], } references_validator(None, json_dict) warning.assert_called_once_with( 'MALFORMED: recid value found in references of %s: %s', '123', 'foo') assert json_dict['references'] == [ {}, {'recid': 456}, ]
def test_references_validator_does_nothing_on_numerical_recids(): json_dict = { 'references': [ { 'recid': 123 }, { 'recid': 456 }, ], } references_validator(None, json_dict) assert json_dict['references'] == [ { 'recid': 123 }, { 'recid': 456 }, ]
def test_references_validator_removes_and_warns_on_non_numerical_recids( warning): json_dict = { 'control_number': 123, 'references': [ { 'recid': 'foo' }, { 'recid': 456 }, ], } references_validator(None, json_dict) warning.assert_called_once_with( 'MALFORMED: recid value found in references of %s: %s', 123, 'foo') assert json_dict['references'] == [ {}, { 'recid': 456 }, ]
def test_references_validator_does_nothing_on_missing_key(): json_dict = {} references_validator(None, json_dict) assert 'references' not in json_dict