Exemplo n.º 1
0
def test_fkw4():
    '''Free Keywords validation invariant error - not all fields set'''
    assert_faulty_keys(fkw4,
                       expected_keys=set(['__after']),
                       expected_invariants=[
                           "You need to fill in the rest free-keyword fields"
                       ])
def test_16():
    terms16 = ThesaurusTerms(
        thesaurus = thesaurus_gemet_concepts,
    ) 

    assert_faulty_keys(terms16,
        expected_keys=['terms'])
Exemplo n.º 3
0
def test_invariants_x21():
    '''Find invariant errors (one on top)'''
    helpers.assert_faulty_keys(x21,
                               expected_keys=set([
                                   '__after', 'contact_info',
                                   'temporal_extent', 'contacts'
                               ]))
def test_14():
    terms14 = ThesaurusTerms(
        terms = ['foo']
    ) 
    
    assert_faulty_keys(terms14,
        expected_keys=['thesaurus'])
Exemplo n.º 5
0
def test_invariants_x23():
    IDataciteMetadata.get('contacts').value_type.required = False
    helpers.assert_faulty_keys(x23,
                               expected_keys=set(
                                   ['contact_info', 'temporal_extent']))
    IDataciteMetadata.get(
        'contacts').value_type.required = True  # dont affect others
Exemplo n.º 6
0
def test_insp2():
    ''' Creation, publication, revision date ranges not valid'''
    assert_faulty_keys(insp2,
                       expected_keys=set(['__after']),
                       expected_invariants=[
                           "later than publication date",
                           "later than last revision date"
                       ])
Exemplo n.º 7
0
def test_17():
    '''Provide a non-existent vocabulary'''

    assert_faulty_keys(thesaurus_baz, expected_keys=['vocabulary'])

    terms17 = ThesaurusTerms(thesaurus=thesaurus_baz, terms=['baz-1', 'baz-2'])

    assert_faulty_keys(terms17, expected_keys=['thesaurus'])
Exemplo n.º 8
0
def test_12():
    terms12 = ThesaurusTerms(thesaurus=thesaurus_gemet_concepts,
                             terms=['accident', 'foo'])

    assert_faulty_keys(
        terms12,
        expected_keys=['__after'],
        expected_invariants=['The following terms do not belong'])
Exemplo n.º 9
0
def test_schema_x11():
    '''Find schema validation errors (x11)'''
    helpers.assert_faulty_keys(x11,
                               expected_keys=set([
                                   'tags', 'url', 'contact_info', 'contacts',
                                   'temporal_extent', 'geometry',
                                   'thematic_category', 'rating', 'grade'
                               ]))
def test_15():
    terms15 = ThesaurusTerms(
        thesaurus = 'i am not a thesaurus object',
        terms = ['foo']
    ) 
    
    assert_faulty_keys(terms15,
        expected_keys=['thesaurus'])
def test_invariants_x22():
    '''Find invariant errors (multiple on top)'''
    helpers.assert_faulty_keys(x22,
        expected_keys = set(['__after', 'contact_info', 'temporal_extent', 'contacts']))

    # Did we catch 2 failed invariants on top?
    errs = x22.validate()
    errs_dict = x22.dictize_errors(errs)
    assert len(errs_dict['__after']) >= 2
def test_invariants_x22():
    '''Find invariant errors (multiple on top)'''
    helpers.assert_faulty_keys(x22,
        expected_keys = set(['__after', 'contact_info', 'temporal_extent', 'contacts']))

    # Did we catch 2 failed invariants on top?
    errs = x22.validate()
    errs_dict = x22.dictize_errors(errs)
    assert len(errs_dict['__after']) >= 2
def test_12():
    terms12 = ThesaurusTerms(
        thesaurus = thesaurus_gemet_concepts,
        terms = ['accident', 'foo']
    )

    assert_faulty_keys(terms12,
        expected_keys = ['__after'], 
        expected_invariants=['The following terms do not belong'])
    def _from_xml(self, infile, expected_errs=[]):
        ser = xml_serializer_for_object(InspireMetadata())

        e = etree.parse(infile)
        assert isinstance(e, etree._ElementTree)
        out = ser.from_xml(e)
        print 'out'
        print out
        assert isinstance(out, InspireMetadata)
        assert_faulty_keys(out, expected_errs)
Exemplo n.º 15
0
    def _from_xml(self, infile, expected_errs=[]):
        ser = xml_serializer_for_object(InspireMetadata())

        e = etree.parse(infile)
        assert isinstance(e, etree._ElementTree)
        out = ser.from_xml(e)
        print 'out'
        print out
        assert isinstance(out, InspireMetadata)
        assert_faulty_keys(out, expected_errs)
Exemplo n.º 16
0
def test_schema_x13():
    '''Find schema validation errors (x13)'''
    helpers.assert_faulty_keys(x13,
                               expected_keys=set([
                                   'tags',
                                   'url',
                                   'contact_info',
                                   'contacts',
                                   'temporal_extent',
                               ]))
def test_17():
    '''Provide a non-existent vocabulary'''
    
    assert_faulty_keys(thesaurus_baz,
        expected_keys=['vocabulary'])
    
    terms17 = ThesaurusTerms(
        thesaurus = thesaurus_baz,
        terms = ['baz-1', 'baz-2']
    ) 

    assert_faulty_keys(terms17,
        expected_keys=['thesaurus'])
Exemplo n.º 18
0
def test_11():
    terms11 = ThesaurusTerms(thesaurus=thesaurus_gemet_concepts,
                             terms=['accident', 'atmosphere'])

    verifyObject(IThesaurus, thesaurus_gemet_concepts)
    verifyObject(IThesaurusTerms, terms11)

    for k in thesaurus_gemet_concepts.vocabulary:
        print k.title, k.value

    assert_faulty_keys(thesaurus_gemet_concepts, expected_keys=[])
    assert_faulty_keys(terms11, expected_keys=[])

    print ' -- to_dict --'
    print terms11.to_dict()
    print ' -- to_dict flat --'
    print terms11.to_dict(flat=True)
def test_11():
    terms11 = ThesaurusTerms(
        thesaurus = thesaurus_gemet_concepts,
        terms = ['accident', 'atmosphere']
    )

    verifyObject(IThesaurus, thesaurus_gemet_concepts)
    verifyObject(IThesaurusTerms, terms11)
    
    for k in thesaurus_gemet_concepts.vocabulary: 
        print k.title, k.value

    assert_faulty_keys(thesaurus_gemet_concepts, expected_keys=[])
    assert_faulty_keys(terms11, expected_keys=[])

    print ' -- to_dict --'
    print terms11.to_dict()
    print ' -- to_dict flat --'
    print terms11.to_dict(flat=True)
Exemplo n.º 20
0
def test_insp9():
    '''Missing Keywords from INSPIRE Data themes'''
    assert_faulty_keys(insp9,
        expected_keys=set(['__after']))
Exemplo n.º 21
0
def test_valid_x3():
    '''Verify a valid object'''
    helpers.assert_faulty_keys(x3, expected_keys=[])
def test_cnf1():
    '''Conformity validation errors date, creation, degree'''
    assert_faulty_keys(cnf1, expected_keys=set(['date', 'date_type', 'degree']))
Exemplo n.º 23
0
def test_schema_x14():
    '''Find schema validation errors (x14)'''
    helpers.assert_faulty_keys(x14,
                               expected_keys=set(
                                   ['tags', 'contact_info', 'contacts']))
def test_rs2():
    ''' Find reference system unicode version error'''
    assert_faulty_keys(rs2)
    assert rs2.code_space == 'CustomSpace'
    assert rs2.version == '5'
Exemplo n.º 25
0
def test_insp93():
    ''' Some free keywords are present'''
    assert_faulty_keys(insp93)
def test_rp2():
    ''' Responsible Party validation errors, empty fields'''
    assert_faulty_keys(rp2, expected_keys=set(['email']))
Exemplo n.º 27
0
def test_insp12():
    '''Missing required topic_category, responsible_party'''
    assert_faulty_keys(insp12,
        expected_keys=set(['topic_category', 'responsible_party']))
def test_insp2():
    ''' Creation, publication, revision date ranges not valid'''
    assert_faulty_keys(insp2,
        expected_keys = set(['__after']), 
        expected_invariants = ["later than publication date", "later than last revision date"]
    )
def test_rp3():
    ''' Responsible Party validation errors, email not correct'''
    assert_faulty_keys(rp3, expected_keys=set(['email']))
Exemplo n.º 30
0
def test_insp11():
    ''' Missing required title, abstract'''
    assert_faulty_keys(insp11, 
        expected_keys=set(['title', 'abstract']))
def test_rp4():
    '''Responsible Party correct schema'''
    assert_faulty_keys(rp_correct, expected_keys=set([]))
Exemplo n.º 32
0
def test_cnf1():
    '''Conformity validation errors date, creation, degree'''
    assert_faulty_keys(cnf1,
                       expected_keys=set(['date', 'date_type', 'degree']))
Exemplo n.º 33
0
def test_rp4():
    '''Responsible Party correct schema'''
    assert_faulty_keys(rp_correct, expected_keys=set([]))
Exemplo n.º 34
0
def test_insp91():
    '''Completely empty keywords'''
    assert_faulty_keys(insp91,
        expected_keys=set(['keywords']))
Exemplo n.º 35
0
def test_insp3():
    ''' Min_length of contact, locator smaller than min_length'''
    assert_faulty_keys(insp3,
        expected_keys=set(['contact', 'locator']))
Exemplo n.º 36
0
def test_insp92():
    ''' Free keywords originating vocabulary dates not set'''
    assert_faulty_keys(insp92,
        expected_keys=set(['free_keywords']))
Exemplo n.º 37
0
def test_insp4():
    '''Temporal-Extent start field (required field in ITemporalExtent) missing'''
    assert_faulty_keys(insp4,
        expected_keys=set(['temporal_extent']))
Exemplo n.º 38
0
def test_fixtures_inspire1():
    '''Everything should be ok'''
    assert_faulty_keys(fixtures.inspire1)
Exemplo n.º 39
0
def test_insp5():
    '''Temporal-Extent (not required field) missing'''
    assert_faulty_keys(insp5)
def test_rp1():
    ''' Responsible Party validation errors, name, email not list'''
    assert_faulty_keys(rp1, expected_keys=set(['organization', 'email', 'role']))
Exemplo n.º 41
0
def test_insp6():
    '''Temporal-Extent wrong date range'''
    assert_faulty_keys(insp6,
        expected_keys=set(['temporal_extent']), expected_invariants=["later than end date"])
def test_rs_correct_2():
    '''Reference system correct schema '''
    assert_faulty_keys(rs5)
Exemplo n.º 43
0
def test_insp7():
    '''Unexpected keywords (not found in vocabularies)'''
    assert_faulty_keys(insp7,
        expected_keys=set(['keywords']))
Exemplo n.º 44
0
def test_invariants_x24():
    helpers.assert_faulty_keys(x24,
                               expected_keys=set(
                                   ['contact_info', 'temporal_extent']))
Exemplo n.º 45
0
def test_insp8():
    '''Wrong Thesaurus name provided'''
    assert_faulty_keys(insp8,
        expected_keys=set(['keywords']))
Exemplo n.º 46
0
def test_cnf2():
    '''Conformity correct schema'''
    assert_faulty_keys(cnf_correct)
def test_cnf2():
    '''Conformity correct schema'''
    assert_faulty_keys(cnf_correct)