def test_record_metadata_schema_empty_fields(): schema = RecordMetadataSchemaV1() dump = {} expected = {} result = schema.dumps(dump).data assert expected == json.loads(result)
def test_record_metadata_schema_returns_number_of_authors(): schema = RecordMetadataSchemaV1() dump = {'authors': [{'full_name': 'author 1'}, {'full_name': 'author 2'}]} expected = 2 result = schema.dumps(dump).data number_of_authors = json.loads(result)['number_of_authors'] assert expected == number_of_authors
def test_record_metadata_schema_uses_existing_number_of_references(): schema = RecordMetadataSchemaV1() dump = {'number_of_references': 2} expected = 2 result = schema.dumps(dump).data number_of_references = json.loads(result)['number_of_references'] assert expected == number_of_references
def test_record_metadata_schema_returns_formatted_date(format_date): schema = RecordMetadataSchemaV1() dump = {'earliest_date': '11/11/2011'} formatted_date = 'Nov, 11, 20111' format_date.return_value = formatted_date expected = {'date': formatted_date} result = schema.dumps(dump).data assert expected == json.loads(result)
def test_record_metadata_schema_returns_number_of_references(): schema = RecordMetadataSchemaV1() dump = { 'references': [ { 'reference': { 'label': '1' } }, { 'reference': { 'label': '2' } }, ] } expected = 2 result = schema.dumps(dump).data number_of_references = json.loads(result)['number_of_references'] assert expected == number_of_references