22import os
33
44import collections
5- import sys
65
76import pytest
87import vcr
98
10- here = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
11- sys .path .insert (0 , here )
12-
139from agentarchives .archivesspace .client import ArchivesSpaceClient , ArchivesSpaceError , CommunicationError
1410
11+
1512THIS_DIR = os .path .dirname (os .path .abspath (__file__ ))
1613AUTH = {
1714 'host' : 'http://localhost:8089' ,
@@ -215,6 +212,7 @@ def test_find_collection_ids_search():
215212 ids = client .find_collection_ids (search_pattern = 'Some' )
216213 assert ids == ['/repositories/2/resources/2' ]
217214
215+
218216@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_count_collection_ids.yaml' ))
219217def test_count_collection_ids ():
220218 client = ArchivesSpaceClient (** AUTH )
@@ -228,6 +226,7 @@ def test_count_collection_ids_search():
228226 ids = client .count_collections (search_pattern = 'Some' )
229227 assert ids == 1
230228
229+
231230@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_find_by_id_refid.yaml' ))
232231def test_find_by_id_refid ():
233232 client = ArchivesSpaceClient (** AUTH )
@@ -240,6 +239,7 @@ def test_find_by_id_refid():
240239 assert item ['title' ] == 'Test AO'
241240 assert item ['levelOfDescription' ] == 'file'
242241
242+
243243@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_augment_ids.yaml' ))
244244def test_augment_ids ():
245245 client = ArchivesSpaceClient (** AUTH )
@@ -250,25 +250,29 @@ def test_augment_ids():
250250 assert data [1 ]['title' ] == 'Some other fonds'
251251 assert data [1 ]['type' ] == 'resource'
252252
253+
253254@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_resource_type.yaml' ))
254255def test_get_resource_type ():
255256 client = ArchivesSpaceClient (** AUTH )
256257 assert client .resource_type ('/repositories/2/resources/2' ) == 'resource'
257258 assert client .resource_type ('/repositories/2/archival_objects/3' ) == 'resource_component'
258259
260+
259261@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_resource_type.yaml' ))
260262def test_get_resource_type_raises_on_invalid_input ():
261263 client = ArchivesSpaceClient (** AUTH )
262264 with pytest .raises (ArchivesSpaceError ):
263265 client .resource_type ('invalid' )
264266
267+
265268@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_identifier_exact_match.yaml' ))
266269def test_identifier_search_exact_match ():
267270 client = ArchivesSpaceClient (** AUTH )
268271 assert client .find_collection_ids (identifier = 'F1' ) == ['/repositories/2/resources/1' ]
269272 assert client .count_collections (identifier = 'F1' ) == 1
270273 assert len (client .find_collections (identifier = 'F1' )) == 1
271274
275+
272276@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_identifier_wildcard.yaml' ))
273277def test_identifier_search_wildcard ():
274278 client = ArchivesSpaceClient (** AUTH )
@@ -281,18 +285,21 @@ def test_identifier_search_wildcard():
281285 assert client .count_collections (identifier = 'F*' ) == 2
282286 assert len (client .find_collections (identifier = 'F*' )) == 2
283287
288+
284289@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_add_child_resource.yaml' ))
285290def test_add_child_resource ():
286291 client = ArchivesSpaceClient (** AUTH )
287292 uri = client .add_child ('/repositories/2/resources/2' , title = 'Test child' , level = 'item' )
288293 assert uri == '/repositories/2/archival_objects/3'
289294
295+
290296@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_add_child_resource_component.yaml' ))
291297def test_add_child_resource_component ():
292298 client = ArchivesSpaceClient (** AUTH )
293299 uri = client .add_child ('/repositories/2/archival_objects/1' , title = 'Test child' , level = 'item' )
294300 assert uri == '/repositories/2/archival_objects/5'
295301
302+
296303@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_adding_child_with_note.yaml' ))
297304def test_adding_child_with_note ():
298305 client = ArchivesSpaceClient (** AUTH )
@@ -302,6 +309,7 @@ def test_adding_child_with_note():
302309 notes = [{'type' : 'odd' , 'content' : 'This is a test note' }])
303310 assert uri == '/repositories/2/archival_objects/24'
304311
312+
305313@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_posting_contentless_note.yaml' ))
306314def test_posting_contentless_note ():
307315 client = ArchivesSpaceClient (** AUTH )
@@ -311,6 +319,7 @@ def test_posting_contentless_note():
311319 notes = [{'type' : 'odd' , 'content' : '' }])
312320 assert client .get_record (uri )['notes' ] == []
313321
322+
314323@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_posting_multiple_notes.yaml' ))
315324def test_posting_multiple_notes ():
316325 client = ArchivesSpaceClient (** AUTH )
@@ -324,6 +333,7 @@ def test_posting_multiple_notes():
324333 assert record ['notes' ][1 ]['type' ] == 'accessrestrict'
325334 assert record ['notes' ][1 ]['subnotes' ][0 ]['content' ] == 'Access'
326335
336+
327337@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_delete_record_resource.yaml' ))
328338def test_delete_record_resource ():
329339 client = ArchivesSpaceClient (** AUTH )
@@ -334,6 +344,7 @@ def test_delete_record_resource():
334344 with pytest .raises (CommunicationError ):
335345 client .get_record (record_id )
336346
347+
337348@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_delete_record_archival_object.yaml' ))
338349def test_delete_record_archival_object ():
339350 client = ArchivesSpaceClient (** AUTH )
@@ -344,6 +355,7 @@ def test_delete_record_archival_object():
344355 with pytest .raises (CommunicationError ):
345356 client .get_record (record_id )
346357
358+
347359@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_edit_archival_object.yaml' ))
348360def test_edit_archival_object ():
349361 client = ArchivesSpaceClient (** AUTH )
@@ -392,6 +404,7 @@ def test_edit_record_empty_note():
392404 updated = client .get_record ('/repositories/2/archival_objects/3' )
393405 assert not updated ['notes' ]
394406
407+
395408@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_edit_record_multiple_notes.yaml' ))
396409def test_edit_record_multiple_notes ():
397410 client = ArchivesSpaceClient (** AUTH )
@@ -416,6 +429,7 @@ def test_edit_record_multiple_notes():
416429 assert updated ['notes' ][1 ]['type' ] == new_record ['notes' ][1 ]['type' ]
417430 assert updated ['notes' ][1 ]['subnotes' ][0 ]['content' ] == new_record ['notes' ][1 ]['content' ]
418431
432+
419433@vcr .use_cassette (os .path .join (THIS_DIR , 'fixtures' , 'test_add_digital_object.yaml' ))
420434def test_add_digital_object ():
421435 client = ArchivesSpaceClient (** AUTH )
0 commit comments