def test_33_get_ore_statement(self): conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW) conn.get_service_document() col = conn.sd.workspaces[0][1][0] e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/") receipt = conn.create(col_iri=col.href, metadata_entry=e) with open(PACKAGE) as pkg: new_receipt = conn.update( dr=receipt, payload=pkg, mimetype=PACKAGE_MIME, filename="update.zip", packaging='http://purl.org/net/sword/package/SimpleZip') # ensure that we have a receipt (the server may not give us one # by default) receipt = conn.get_deposit_receipt(receipt.location) assert receipt.ore_statement_iri is not None # get the statement statement = conn.get_ore_sword_statement(receipt.ore_statement_iri) assert isinstance(statement, Ore_Sword_Statement) # some specific things that we can assert about the Statement # 1 - it should have the original deposits listed # 2 - it should have the aggregated resources listed # 3 - it should have the correct state # 4 - the dom should contain all the relevant metadata # check the original deposits od_uri = None assert len(statement.original_deposits) == 1 for od in statement.original_deposits: assert "update.zip" in od.uri assert od.is_original_deposit assert od.deposited_on is not None # assert od.deposited_by == SSS_UN # FIXME: this may not work until we get auth sorted out assert od.deposited_on_behalf_of is None od_uri = od.uri # check the aggregated resources assert len(statement.resources) == 1 for ar in statement.resources: # should be the same resource assert od_uri == ar.uri # check the states assert len(statement.states) == 1 assert statement.states[0][ 0] == "http://databank.ox.ac.uk/state/ZipFileAdded" print etree.tostring(statement.dom, pretty_print=True) # check the metadata md_count = 0 for e in statement.dom.findall(RDF + "Description"): for element in e.getchildren(): if element.tag == DC + "title": assert element.text.strip() == "An entry only deposit" md_count += 1 elif element.tag == DC + "abstract": assert element.text.strip() == "abstract" md_count += 1 elif element.tag == DC + "identifier": resource = element.attrib.get(RDF + "resource", None) if resource is not None: # because we know that there is going to be more than one identifier assert element.attrib.get( RDF + "resource") == "http://whatever/" md_count += 1 print "Metadata Count: " + str(md_count) assert md_count == 3
def test_33_get_ore_statement(self): conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW) conn.get_service_document() col = conn.sd.workspaces[0][1][0] e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/") receipt = conn.create(col_iri = col.href, metadata_entry = e) with open(PACKAGE) as pkg: new_receipt = conn.update(dr = receipt, payload=pkg, mimetype=PACKAGE_MIME, filename="update.zip", packaging='http://purl.org/net/sword/package/SimpleZip') # ensure that we have a receipt (the server may not give us one # by default) receipt = conn.get_deposit_receipt(receipt.location) assert receipt.ore_statement_iri is not None # get the statement statement = conn.get_ore_sword_statement(receipt.ore_statement_iri) assert isinstance(statement, Ore_Sword_Statement) # some specific things that we can assert about the Statement # 1 - it should have the original deposits listed # 2 - it should have the aggregated resources listed # 3 - it should have the correct state # 4 - the dom should contain all the relevant metadata # check the original deposits od_uri = None assert len(statement.original_deposits) == 1 for od in statement.original_deposits: assert "update.zip" in od.uri assert od.is_original_deposit assert od.deposited_on is not None # assert od.deposited_by == SSS_UN # FIXME: this may not work until we get auth sorted out assert od.deposited_on_behalf_of is None od_uri = od.uri # check the aggregated resources assert len(statement.resources) == 1 for ar in statement.resources: # should be the same resource assert od_uri == ar.uri # check the states assert len(statement.states) == 1 assert statement.states[0][0] == "http://databank.ox.ac.uk/state/ZipFileAdded" print etree.tostring(statement.dom, pretty_print=True) # check the metadata md_count = 0 for e in statement.dom.findall(RDF + "Description"): for element in e.getchildren(): if element.tag == DC + "title": assert element.text.strip() == "An entry only deposit" md_count += 1 elif element.tag == DC + "abstract": assert element.text.strip() == "abstract" md_count += 1 elif element.tag == DC + "identifier": resource = element.attrib.get(RDF + "resource", None) if resource is not None: # because we know that there is going to be more than one identifier assert element.attrib.get(RDF + "resource") == "http://whatever/" md_count += 1 print "Metadata Count: " + str(md_count) assert md_count == 3