Skip to content

Commit

Permalink
applied requested changes
Browse files Browse the repository at this point in the history
Signed-off-by: Spiros Delviniotis <[email protected]>
  • Loading branch information
spirosdelviniotis committed May 10, 2017
1 parent 8c9fab2 commit 3824bc9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
6 changes: 3 additions & 3 deletions hepcrawl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def local_list_files(local_folder, target_folder):

def list_missing_files(remote_folder, target_folder, file_names):
missing_files = []
for filename in file_names:
destination_file = os.path.join(target_folder, filename)
source_file = os.path.join(remote_folder, filename)
for file_name in file_names:
destination_file = os.path.join(target_folder, file_name)
source_file = os.path.join(remote_folder, file_name)
if not os.path.exists(destination_file):
missing_files.append(source_file)

Expand Down
31 changes: 21 additions & 10 deletions tests/functional/WSP/test_wsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def expected_results():

@pytest.fixture(scope="function")
def set_up_ftp_environment():
netrc_location = os.path.join(os.path.dirname(
os.path.realpath(__file__)),
netrc_location = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
os.path.join('fixtures', 'ftp_server', '.netrc')
)

Expand All @@ -72,9 +72,9 @@ def set_up_ftp_environment():

@pytest.fixture(scope="function")
def set_up_local_environment():
package_location = os.path.join(os.path.dirname(
os.path.realpath(__file__)),
'fixtures/ftp_server/WSP/'
package_location = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
os.path.join('fixtures', 'ftp_server', 'WSP')
)

yield {
Expand All @@ -86,7 +86,16 @@ def set_up_local_environment():
}

clean_dir()
clean_dir(package_location + 'IDAQPv20i01-03160015-1510863')
remove_generated_files(package_location)


def remove_generated_files(package_location):
for _, dirs, files in os.walk(package_location):
for dir_name in dirs:
clean_dir(os.path.join(package_location, dir_name))
for file_name in files:
if '.zip' not in file_name:
os.unlink(os.path.join(package_location, file_name))


def clean_dir(path='/tmp/WSP/'):
Expand All @@ -110,8 +119,10 @@ def test_wsp_ftp(set_up_ftp_environment, expected_results):
**set_up_ftp_environment.get('CRAWLER_ARGUMENTS')
)

assert [override_generated_fields(result) for result in results] == \
[override_generated_fields(expected) for expected in expected_results]
gotten_results = [override_generated_fields(result) for result in results]
expected_results = [override_generated_fields(expected) for expected in expected_results]

assert gotten_results == expected_results


def test_wsp_local_package_path(set_up_local_environment, expected_results):
Expand All @@ -128,7 +139,7 @@ def test_wsp_local_package_path(set_up_local_environment, expected_results):
**set_up_local_environment.get('CRAWLER_ARGUMENTS')
)

gottern_results = [override_generated_fields(result) for result in results]
gotten_results = [override_generated_fields(result) for result in results]
expected_results = [override_generated_fields(expected) for expected in expected_results]

assert gottern_results == expected_results
assert gotten_results == expected_results

0 comments on commit 3824bc9

Please sign in to comment.