예제 #1
0
def test_from_string():
    # we are only testing that the string results in a Record instance with 'raw_rdf' attribute
    # the fact that it's invalid should be tested by the parser.
    test_string = '<?xml version="1.0" encoding="UTF-8"?><rdf:RDF>dummy</rdf:RDF>'

    with pytest.raises(Exception) as excinfo:
        record = Record.from_string(test_string)
        assert record.raw_rdf == test_string

        assert 'Could not parse URI from given record.' in str(excinfo.value)
예제 #2
0
def test_all_empty_except_uri():
    # although not a valid SOCH 1.1 RDF we should be fogiving and support it
    test_string = '''<?xml version="1.0" encoding="UTF-8"?>
                    <rdf:RDF 
                        xmlns:ns1="http://kulturarvsdata.se/ksamsok#" 
                        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                        <rdf:Description rdf:about="http://kulturarvsdata.se/KBG/photo/KBGF051559">
                        </rdf:Description>
                    </rdf:RDF>
                 '''

    record = Record.from_string(test_string)

    assert record.uri == 'http://kulturarvsdata.se/KBG/photo/KBGF051559'
예제 #3
0
def test_not_able_to_parse_error():
    with pytest.raises(Exception) as excinfo:
        Record.from_string('crap')
        assert 'Could not parse URI from given record.' in str(excinfo.value)