Example #1
0
def test_language():
    """Test resource type."""
    msv1 = MetadataSchemaV1(partial=['language'])
    data, errors = msv1.load(dict(language='eng'))
    assert data['language'] == 'eng'
    assert 'language' not in errors
    data, errors = msv1.load(dict(language='English'))
    assert 'language' in errors
    data, errors = msv1.load(dict())
    assert 'language' not in errors
Example #2
0
def test_invalid_resource_type(val):
    """Test resource type."""
    data, errors = MetadataSchemaV1(partial=['resource_type']).load(
        dict(resource_type=val))
    assert 'resource_type' in errors
Example #3
0
def test_valid_resource_type(val, expected):
    """Test resource type."""
    data, errors = MetadataSchemaV1(partial=['resource_type']).load(
        dict(resource_type=val))
    assert data['resource_type'] == val if expected is None else expected
Example #4
0
def test_invalid_doi(input_val, ctx):
    """Test DOI."""
    data, errors = MetadataSchemaV1(partial=['doi'],
                                    context=ctx).load(dict(doi=input_val))
    assert 'doi' in errors
    assert 'doi' not in data
Example #5
0
def test_valid_doi(input_val, ctx):
    """Test DOI."""
    data, errors = MetadataSchemaV1(partial=['doi'],
                                    context=ctx).load(dict(doi=input_val))
    assert data['doi'] == idutils.normalize_doi(input_val.strip())
Example #6
0
def test_invalid_publication_date(val):
    """Test resource type."""
    data, errors = MetadataSchemaV1(partial=['publication_date']).load(
        dict(publication_date=val))
    assert 'publication_date' in errors
    assert 'publication_date' not in data
Example #7
0
def test_valid_publication_date(val, expected):
    """Test resource type."""
    data, errors = MetadataSchemaV1(partial=['publication_date']).load(
        dict(publication_date=val) if val is not None else dict())
    assert data['publication_date'] == val if expected is None else expected