Skip to content

Commit bf5ad31

Browse files
committed
Make flake8 check mandatory
1 parent 24642e3 commit bf5ad31

File tree

11 files changed

+54
-50
lines changed

11 files changed

+54
-50
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,3 @@ matrix:
2020
env: TOXENV=py34
2121
- python: "3.6"
2222
env: TOXENV=flake8
23-
allow_failures:
24-
- python: "3.6"
25-
env: TOXENV=flake8
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .client import *
1+
from .client import * # noqa

agentarchives/archivesspace/client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,9 @@ def edit_record(self, new_record):
306306

307307
self._post(record_id, data=json.dumps(record))
308308

309-
310309
def get_levels_of_description(self):
311-
"""
312-
Returns an array of all levels of description defined in this ArchivesSpace instance.
313-
"""
310+
"""Returns an array of all levels of description defined in this
311+
ArchivesSpace instance."""
314312
if not hasattr(self, 'levels_of_description'):
315313
# TODO: * fetch human-formatted strings
316314
# * is hardcoding this ID okay?
@@ -752,7 +750,7 @@ def add_digital_object(self, parent_archival_object, identifier, title=None, uri
752750
"xlink_actuate_attribute": xlink_actuate,
753751
}]
754752

755-
note_digital_object_type = ["summary", "bioghist", "accessrestrict", "userestrict", "custodhist", "dimensions", "edition", "extent","altformavail", "originalsloc", "note", "acqinfo", "inscription", "langmaterial", "legalstatus", "physdesc", "prefercite", "processinfo", "relatedmaterial"]
753+
note_digital_object_type = ["summary", "bioghist", "accessrestrict", "userestrict", "custodhist", "dimensions", "edition", "extent", "altformavail", "originalsloc", "note", "acqinfo", "inscription", "langmaterial", "legalstatus", "physdesc", "prefercite", "processinfo", "relatedmaterial", ]
756754

757755
if inherit_notes:
758756
for pnote in parent_record["notes"]:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .client import *
1+
from .client import * # noqa

agentarchives/archivists_toolkit/client.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def get_resource_component_and_children(self, resource_id, resource_type='collec
221221
# can use it to share state during recursion
222222

223223
recurse_max_level = kwargs.get('recurse_max_level', False)
224-
query = kwargs.get('search_pattern', '')
224+
query = kwargs.get('search_pattern', '')
225225

226226
# intialize sort position if this is the beginning of recursion
227227
if level == 1:
@@ -237,26 +237,26 @@ def get_resource_component_and_children(self, resource_id, resource_type='collec
237237
cursor.execute("SELECT title, dateExpression, resourceIdentifier1, resourceLevel FROM Resources WHERE resourceid=%s", (resource_id))
238238

239239
for row in cursor.fetchall():
240-
resource_data['id'] = resource_id
241-
resource_data['type'] = 'resource'
242-
resource_data['sortPosition'] = sort_data['position']
243-
resource_data['title'] = row[0]
240+
resource_data['id'] = resource_id
241+
resource_data['type'] = 'resource'
242+
resource_data['sortPosition'] = sort_data['position']
243+
resource_data['title'] = row[0]
244244
# TODO reformat dates from the separate date fields, like ArchivesSpaceClient?
245-
resource_data['dates'] = row[1]
246-
resource_data['date_expression'] = row[1]
247-
resource_data['identifier'] = row[2]
245+
resource_data['dates'] = row[1]
246+
resource_data['date_expression'] = row[1]
247+
resource_data['identifier'] = row[2]
248248
resource_data['levelOfDescription'] = row[3]
249249
else:
250250
cursor.execute("SELECT title, dateExpression, persistentID, resourceLevel FROM ResourcesComponents WHERE resourceComponentId=%s", (resource_id))
251251

252252
for row in cursor.fetchall():
253-
resource_data['id'] = resource_id
254-
resource_data['type'] = 'resource_component'
255-
resource_data['sortPosition'] = sort_data['position']
256-
resource_data['title'] = row[0]
257-
resource_data['dates'] = row[1]
258-
resource_data['date_expression'] = row[1]
259-
resource_data['identifier'] = row[2]
253+
resource_data['id'] = resource_id
254+
resource_data['type'] = 'resource_component'
255+
resource_data['sortPosition'] = sort_data['position']
256+
resource_data['title'] = row[0]
257+
resource_data['dates'] = row[1]
258+
resource_data['date_expression'] = row[1]
259+
resource_data['identifier'] = row[2]
260260
resource_data['levelOfDescription'] = row[3]
261261

262262
# fetch children if we haven't reached the maximum recursion level

agentarchives/atom/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .client import *
1+
from .client import * # noqa

agentarchives/atom/client.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ def get_record(self, record_id):
144144

145145
def _format_date_from_atom(self, date):
146146
# Map AtoM date specification to generic
147-
updated_date = {}
148-
149147
date_mapping = {
150148
'start_date': 'begin',
151149
'end_date': 'end',
@@ -200,7 +198,7 @@ def edit_record(self, new_record):
200198
# within that note.
201199
# If the record already has at least one note, then replace the first note
202200
# within that record with this one.
203-
if not 'notes' in record or record['notes'] == []:
201+
if 'notes' not in record or record['notes'] == []:
204202
record['notes'] = [new_note]
205203
else:
206204
record['notes'][0] = new_note
@@ -222,9 +220,9 @@ def edit_record(self, new_record):
222220
# Map agentarchives date specification to AtoM specification
223221
date_mapping = {
224222
'start_date': 'start_date',
225-
#'begin': 'start_date',
223+
# 'begin': 'start_date',
226224
'end_date': 'end_date',
227-
#'end': 'end_date',
225+
# 'end': 'end_date',
228226
'date_expression': 'date'
229227
}
230228

@@ -539,8 +537,8 @@ def augment_resource_ids(self, resource_ids):
539537
"""
540538
resources_augmented = []
541539
for id in resource_ids:
542-
#resource_data = self.get_resource_component_and_children(id, recurse_max_level=2)
543-
#resources_augmented.append(resource_data)
540+
# resource_data = self.get_resource_component_and_children(id, recurse_max_level=2)
541+
# resources_augmented.append(resource_data)
544542
resources_augmented.append(
545543
self.get_resource_component_and_children(id, recurse_max_level=2)
546544
)

tests/__init__.py

Whitespace-only changes.

tests/test_archivesspace_client.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
import os
33

44
import collections
5-
import sys
65

76
import pytest
87
import vcr
98

10-
here = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
11-
sys.path.insert(0, here)
12-
139
from agentarchives.archivesspace.client import ArchivesSpaceClient, ArchivesSpaceError, CommunicationError
1410

11+
1512
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
1613
AUTH = {
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'))
219217
def 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'))
232231
def 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'))
244244
def 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'))
254255
def 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'))
260262
def 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'))
266269
def 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'))
273277
def 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'))
285290
def 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'))
291297
def 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'))
297304
def 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'))
306314
def 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'))
315324
def 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'))
328338
def 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'))
338349
def 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'))
348360
def 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'))
396409
def 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'))
420434
def test_add_digital_object():
421435
client = ArchivesSpaceClient(**AUTH)

tests/test_atom_client.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22
import os
33

44
import pytest
5-
import sys
65
import vcr
76

8-
here = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
9-
sys.path.insert(0, here)
10-
11-
from agentarchives.atom.client import AtomClient, AtomError, CommunicationError
7+
from agentarchives.atom.client import AtomClient, CommunicationError
128

139
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
1410
AUTH = {
@@ -21,7 +17,7 @@
2117
def test_levels_of_description():
2218
client = AtomClient(**AUTH)
2319
levels = client.get_levels_of_description()
24-
assert levels == [u'Collection', u'File', u'Fonds', u'Item', u'Part', u'Series', u'Subfonds', u'Subseries']
20+
assert levels == [u'Collection', u'File', u'Fonds', u'Item', u'Part', u'Series', u'Subfonds', u'Subseries']
2521

2622

2723
@vcr.use_cassette(os.path.join(THIS_DIR, 'fixtures/atom', 'test_listing_collections.yaml'))
@@ -125,7 +121,7 @@ def test_find_resource_children_recursion_level():
125121
assert data['has_children'] is True
126122

127123

128-
@vcr.use_cassette(os.path.join(THIS_DIR, 'fixtures/atom', 'test_find_resource_children_recursion_level_two.yaml'))
124+
@vcr.use_cassette(os.path.join(THIS_DIR, 'fixtures/atom', 'test_find_resource_children_recursion_level_two.yaml')) # noqa
129125
def test_find_resource_children_recursion_level():
130126
client = AtomClient(**AUTH)
131127
data = client.get_resource_component_and_children('test-fonds',
@@ -208,19 +204,19 @@ def test_add_child_resource_component():
208204
def test_adding_child_with_note():
209205
client = AtomClient(**AUTH)
210206
slug = client.add_child('test-fonds',
211-
title='Another subfonds',
212-
level='subfonds',
213-
notes=[{'type': 'general', 'content': 'This is a test note'}])
207+
title='Another subfonds',
208+
level='subfonds',
209+
notes=[{'type': 'general', 'content': 'This is a test note'}])
214210
assert slug == 'another-subfonds'
215211

216212

217213
@vcr.use_cassette(os.path.join(THIS_DIR, 'fixtures/atom', 'test_posting_contentless_note.yaml'))
218214
def test_posting_contentless_note():
219215
client = AtomClient(**AUTH)
220216
slug = client.add_child('test-fonds',
221-
title='Yet another subfonds',
222-
level='subfonds',
223-
notes=[{'type': 'general', 'content': ''}])
217+
title='Yet another subfonds',
218+
level='subfonds',
219+
notes=[{'type': 'general', 'content': ''}])
224220
assert client.get_record(slug)['notes'] == []
225221

226222

0 commit comments

Comments
 (0)