Skip to content

Commit

Permalink
Fixing Windows tmp file issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mcqueary committed Dec 15, 2023
1 parent f7ce1a9 commit 60b8067
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def silence_tqdm():
del os.environ["TQDM_MININTERVAL"]


@pytest.fixture(autouse=True)
@pytest.fixture
def text_file_with_bad_url():
"""Creates a text file containing a single memorial URL"""
with tempfile.NamedTemporaryFile(delete=False) as tf:
Expand All @@ -41,7 +41,7 @@ def text_file_with_bad_url():
yield


@pytest.fixture(autouse=True, scope="module")
@pytest.fixture
def single_line_text_file():
"""Creates a text file containing a single memorial URL"""
with tempfile.NamedTemporaryFile(delete=False) as tf:
Expand All @@ -51,7 +51,7 @@ def single_line_text_file():
yield


@pytest.fixture(autouse=True, scope="module")
@pytest.fixture
def multi_line_with_file_urls():
"""Creates a text file containing several memorial URLs, one per line"""
file_urls = [
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_cli_scrape_file_does_not_exist(helpers, database):
"name, cassette",
[("grace-brewster-hopper", pytest.vcr_cassettes + "test-cli-scrape-file.yaml")],
)
def test_cli_scrape_file(name, cassette, helpers, database):
def test_cli_scrape_file(name, cassette, helpers, database, multi_line_with_file_urls):
with vcr.use_cassette(cassette):
person = pytest.helpers.load_memorial_from_json(name)
url_file = os.getenv("MULTI_LINE_TEST_FILE")
Expand All @@ -102,7 +102,9 @@ def test_cli_scrape_file(name, cassette, helpers, database):
assert m.memorial_id == mem_id


def test_cli_scrape_file_with_invalid_url(helpers, caplog, database):
def test_cli_scrape_file_with_invalid_url(
helpers, caplog, database, text_file_with_bad_url
):
url_file = os.getenv("BAD_DATA_FILENAME")
command = "scrape-file {}".format(url_file)
helpers.graver_cli(command)
Expand All @@ -125,7 +127,7 @@ def test_cli_scrape_url(url, helpers, database):
assert m.memorial_id == 49636099


def test_cli_scrape_file_with_bad_urls(helpers, database):
def test_cli_scrape_file_with_bad_urls(helpers, database, text_file_with_bad_url):
url_file = os.getenv("BAD_DATA_FILENAME")
db = os.getenv("DATABASE_NAME")
command = "scrape-file {} --db {}".format(url_file, db)
Expand Down Expand Up @@ -155,7 +157,9 @@ def test_cli_scrape_url_with_bad_url(url, helpers, caplog, database):
"george-washington",
],
)
def test_cli_scrape_file_with_single_url_file(name, helpers, database):
def test_cli_scrape_file_with_single_url_file(
name, helpers, database, single_line_text_file
):
expected = pytest.helpers.load_memorial_from_json(name)
cassette = f"{pytest.vcr_cassettes}{name}.yaml"
with vcr.use_cassette(cassette):
Expand Down

0 comments on commit 60b8067

Please sign in to comment.