Skip to content

Commit

Permalink
tests: support for scrapy-crawl-once
Browse files Browse the repository at this point in the history
Addresses inspirehep#161

Signed-off-by: Spiros Delviniotis <[email protected]>
  • Loading branch information
spirosdelviniotis committed Aug 21, 2017
1 parent dafcd3b commit 06e106f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions hepcrawl/testlib/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import os
import json
import shutil

from scrapy.http import Request, TextResponse
from scrapy.selector import Selector
Expand Down Expand Up @@ -131,3 +132,7 @@ def expected_json_results_from_file(*path_chunks, **kwargs):
expected_data = json.load(fd)

return expected_data


def clean_dir(path='/tmp/WSP/'):
shutil.rmtree(path, ignore_errors=True)
4 changes: 4 additions & 0 deletions tests/functional/arxiv/test_arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from __future__ import absolute_import, division, print_function

import os
from time import sleep
import pytest

Expand All @@ -20,6 +21,7 @@
from hepcrawl.testlib.fixtures import (
get_test_suite_path,
expected_json_results_from_file,
clean_dir,
)


Expand Down Expand Up @@ -51,6 +53,8 @@ def set_up_local_environment():
}
}

clean_dir(path=os.path.join(os.getcwd(), '.scrapy'))


@pytest.mark.parametrize(
'expected_results',
Expand Down
8 changes: 3 additions & 5 deletions tests/functional/wsp/test_wsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

import pytest
import os
import shutil

from time import sleep

from hepcrawl.testlib.celery_monitor import CeleryMonitor
from hepcrawl.testlib.fixtures import (
get_test_suite_path,
expected_json_results_from_file,
clean_dir,
)
from hepcrawl.testlib.tasks import app as celery_app
from hepcrawl.testlib.utils import get_crawler_instance
Expand Down Expand Up @@ -56,6 +56,7 @@ def set_up_ftp_environment():
}

clean_dir()
clean_dir(path=os.path.join(os.getcwd(), '.scrapy'))


@pytest.fixture(scope="function")
Expand All @@ -81,6 +82,7 @@ def set_up_local_environment():

def remove_generated_files(package_location):
clean_dir()
clean_dir(path=os.path.join(os.getcwd(), '.scrapy'))

_, dirs, files = next(os.walk(package_location))
for dir_name in dirs:
Expand All @@ -90,10 +92,6 @@ def remove_generated_files(package_location):
os.unlink(os.path.join(package_location, file_name))


def clean_dir(path='/tmp/WSP/'):
shutil.rmtree(path, ignore_errors=True)


@pytest.mark.parametrize(
'expected_results',
[
Expand Down

0 comments on commit 06e106f

Please sign in to comment.