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'])
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'])
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
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_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'])
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 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_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)
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'])
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)
def test_insp9(): '''Missing Keywords from INSPIRE Data themes''' assert_faulty_keys(insp9, expected_keys=set(['__after']))
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']))
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'
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']))
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']))
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([]))
def test_insp91(): '''Completely empty keywords''' assert_faulty_keys(insp91, expected_keys=set(['keywords']))
def test_insp3(): ''' Min_length of contact, locator smaller than min_length''' assert_faulty_keys(insp3, expected_keys=set(['contact', 'locator']))
def test_insp92(): ''' Free keywords originating vocabulary dates not set''' assert_faulty_keys(insp92, expected_keys=set(['free_keywords']))
def test_insp4(): '''Temporal-Extent start field (required field in ITemporalExtent) missing''' assert_faulty_keys(insp4, expected_keys=set(['temporal_extent']))
def test_fixtures_inspire1(): '''Everything should be ok''' assert_faulty_keys(fixtures.inspire1)
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']))
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)
def test_insp7(): '''Unexpected keywords (not found in vocabularies)''' assert_faulty_keys(insp7, expected_keys=set(['keywords']))
def test_invariants_x24(): helpers.assert_faulty_keys(x24, expected_keys=set( ['contact_info', 'temporal_extent']))
def test_insp8(): '''Wrong Thesaurus name provided''' assert_faulty_keys(insp8, expected_keys=set(['keywords']))
def test_cnf2(): '''Conformity correct schema''' assert_faulty_keys(cnf_correct)