-
Notifications
You must be signed in to change notification settings - Fork 178
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
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
api/tests/opentrons/protocols/parameters/test_parameter_file_reader.py
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,26 @@ | ||
import pytest | ||
from pathlib import Path | ||
from tempfile import NamedTemporaryFile | ||
|
||
from opentrons.protocols.parameters.exceptions import RuntimeParameterRequired | ||
from opentrons.protocols.parameters import parameter_file_reader as subject | ||
|
||
|
||
def test_open_file_path() -> None: | ||
"""It should open a temporary file handler given a path.""" | ||
with NamedTemporaryFile("r+") as file_to_open: | ||
file_to_open.write("Hello World\n") | ||
file_to_open.flush() | ||
|
||
result = subject.open_file_path(Path(file_to_open.name)) | ||
|
||
assert result.readable() | ||
assert not result.writable() | ||
assert result.read() == "Hello World\n" | ||
result.close() | ||
|
||
|
||
def test_open_file_path_raises() -> None: | ||
"""It should raise of no file path is provided.""" | ||
with pytest.raises(RuntimeParameterRequired): | ||
subject.open_file_path(None) |