forked from nchammas/flintrock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_scripts.py
38 lines (31 loc) · 942 Bytes
/
test_scripts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import subprocess
import tempfile
import pytest
@pytest.fixture(scope='module')
def tgz_file(request):
with tempfile.NamedTemporaryFile() as source_file:
source_file.file.write('Hi!'.encode('utf-8'))
tgz_file_name = source_file.name + '.tgz'
subprocess.run(
['tar', 'czf', tgz_file_name, source_file.name],
check=True,
)
def destroy():
subprocess.run(
['rm', tgz_file_name],
check=True,
)
request.addfinalizer(destroy)
return tgz_file_name
def test_download_package(project_root_dir, tgz_file):
with tempfile.TemporaryDirectory() as temp_dir:
subprocess.run(
[
'python',
os.path.join(project_root_dir, 'flintrock/scripts/download-package.py'),
'file://' + tgz_file,
temp_dir,
],
check=True,
)