-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8157f6a
commit eb6db65
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
|
||
from grpc4bmi.utils import stage_config_file | ||
|
||
|
||
class TestStageConfigFile: | ||
def test_inside_inputdir(self, tmpdir): | ||
input_dir = tmpdir.mkdir('input') | ||
c = input_dir.join('config.cfg') | ||
c.write("something") | ||
|
||
result = stage_config_file(c, input_dir, input_mount_point='/data/input') | ||
assert result == '/data/input/config.cfg' | ||
|
||
def test_outside_inputdir(self, tmpdir): | ||
input_dir = tmpdir.mkdir('input') | ||
c = tmpdir.join('config.cfg') | ||
c.write("something") | ||
|
||
result = stage_config_file(c, input_dir, input_mount_point='/data/input') | ||
assert result == '/data/input/config.cfg' | ||
|
||
def test_outside_inputdir_beforeconfig(self, tmpdir): | ||
input_dir = tmpdir.mkdir('ainput') | ||
c = tmpdir.join('config.cfg') | ||
c.write("something") | ||
|
||
result = stage_config_file(c, input_dir, input_mount_point='/data/input') | ||
assert result == '/data/input/config.cfg' | ||
|
||
def test_cfg_in_container(self, tmpdir): | ||
input_dir = tmpdir.mkdir('input') | ||
|
||
c = '/somewhere/config.cfg' | ||
result = stage_config_file(c, input_dir, input_mount_point='/data/input') | ||
assert result == c | ||
|
||
def test_noinputdir(self, tmpdir): | ||
c = tmpdir.join('config.cfg') | ||
c.write("something") | ||
|
||
with pytest.raises(Exception) as exc_info: | ||
stage_config_file(c, None, None) | ||
assert str(exc_info.value).startswith('Unable to copy') |