def test_08_advanced_create_resource_with_entry(self): conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO) 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/") e.register_namespace("oxds", "http://databank.ox.ac.uk/terms/") e.add_field("oxds_whatever", "whatever") receipt = conn.create(col_iri=col.href, metadata_entry=e, in_progress=True, suggested_identifier=str(uuid.uuid4())) assert receipt.code == 201 assert receipt.location != None # these last two assertions are contingent on if we actually get a # receipt back from the server (which we might not legitimately get) assert receipt.dom is None or receipt.parsed == True assert receipt.dom is None or receipt.valid == True
def __init__(self, owner): raise NotImplementedError c = Connection(SD_URI, user_name = owner.username, user_pass=owner.password) c.get_service_document() # pick the first collection within the first workspace: workspace_1_title, workspace_1_collections = c.workspaces[0] collection = workspace_1_collections[0] # upload "package.zip" to this collection as a new (binary) resource: with open("package.zip", "r") as pkg: receipt = c.create(col_iri = collection.href, payload = pkg, mimetype = "application/zip", filename = "package.zip", packaging = 'http://purl.org/net/sword/package/Binary', in_progress = True) # As the deposit isn't yet finished # Add a metadata record to this newly created resource (or 'container') from sword2 import Entry # Entry can be passed keyword parameters to add metadata to the entry (namespace + '_' + tagname) e = Entry(id="atomid", title="atom-title", dcterms_abstract = "Info about the resource....", ) # to add a new namespace: e.register_namespace('skos', 'http://www.w3.org/2004/02/skos/core#') e.add_field("skos_Concept", "...") # Update the metadata entry to the resource: updated_receipt = c.update(metadata_entry = e, dr = receipt, # use the receipt to discover the right URI to use in_progress = False) # finish the deposit
def test_04_init_add_namespace(self): e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", author={ 'name': 'Ben', 'email': '*****@*****.**' }) e.register_namespace("mylocal", "info:localnamespace") assert "mylocal" in e.add_ns
def test_07_init_add_new_ns_field(self): e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", author={ 'name': 'Ben', 'email': '*****@*****.**' }) e.register_namespace("mylocal", "info:localnamespace") e.add_field("mylocal_issued", "2003") assert e.entry.find(NS['mylocal'] % 'issued') != None assert e.entry.find(NS['mylocal'] % 'issued').text == "2003"
def test_08_init_add_new_ns_fields(self): e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", author={'name':'Ben', 'email':'*****@*****.**'}) e.register_namespace("mylocal", "info:localnamespace") e.add_fields(mylocal_foobar="2009", updated="2010", mylocal_description="A verbose and new description") assert e.entry.find(NS['atom'] % 'updated') != None assert e.entry.find(NS['atom'] % 'updated').text == "2010" assert e.entry.find(NS['mylocal'] % 'foobar') != None assert e.entry.find(NS['mylocal'] % 'foobar').text == "2009" assert e.entry.find(NS['mylocal'] % 'description') != None assert e.entry.find(NS['mylocal'] % 'description').text == "A verbose and new description"
def test_08_advanced_create_resource_with_entry(self): conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO) 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/") e.register_namespace("oxds", "http://databank.ox.ac.uk/terms/") e.add_field("oxds_whatever", "whatever") receipt = conn.create(col_iri = col.href, metadata_entry = e, in_progress = True, suggested_identifier = str(uuid.uuid4())) assert receipt.code == 201 assert receipt.location != None # these last two assertions are contingent on if we actually get a # receipt back from the server (which we might not legitimately get) assert receipt.dom is None or receipt.parsed == True assert receipt.dom is None or receipt.valid == True
def test_07_init_add_new_ns_field(self): e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", author={'name':'Ben', 'email':'*****@*****.**'}) e.register_namespace("mylocal", "info:localnamespace") e.add_field("mylocal_issued", "2003") assert e.entry.find(NS['mylocal'] % 'issued') != None assert e.entry.find(NS['mylocal'] % 'issued').text == "2003"
def test_04_init_add_namespace(self): e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", author={'name':'Ben', 'email':'*****@*****.**'}) e.register_namespace("mylocal", "info:localnamespace") assert "mylocal" in e.add_ns