Skip to content

Commit

Permalink
functional.desy: adapt to documents structure
Browse files Browse the repository at this point in the history
Signed-off-by: David Caro <[email protected]>
  • Loading branch information
david-caro committed Nov 1, 2017
1 parent cb5a69b commit 5fb3a5c
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions tests/functional/desy/test_desy.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,38 +63,14 @@ def _override(field_key, original_dict, backup_dict, new_value):
return clean_record


def assert_files_equal(file_1, file_2):
"""Compares two files calculating the md5 hash."""
def _generate_md5_hash(file_path):
hasher = hashlib.md5()
with open(str(file_path), 'rb') as fd:
buf = fd.read()
hasher.update(buf)
return hasher.hexdigest()

file_1_hash = _generate_md5_hash(file_1)
file_2_hash = _generate_md5_hash(file_2)
assert file_1_hash == file_2_hash


def assert_documents_content_matches_expected(record):
for documents_field in record.get('documents', []):
assert_document_content_matches_expected(documents_field)


def assert_document_content_matches_expected(documents_field):
expected_file_name = get_file_name_from_documents(documents_field)
assert_files_equal(expected_file_name, documents_field['path'])


def get_file_name_from_documents(documents_field):
file_path = get_test_suite_path(
'desy',
'fixtures',
'ftp_server',
'DESY',
'FFT',
documents_field['filename'] + documents_field['format'],
documents_field['key'],
test_suite='functional',
)
return file_path
Expand Down Expand Up @@ -213,6 +189,3 @@ def test_desy(
)

assert gotten_results == expected_results

for record in gotten_results:
assert_documents_content_matches_expected(record)

0 comments on commit 5fb3a5c

Please sign in to comment.