Skip to content

Commit

Permalink
test for parameter file reader
Browse files Browse the repository at this point in the history
  • Loading branch information
jbleon95 committed Aug 6, 2024
1 parent 7e2979f commit c2561fd
Showing 1 changed file with 26 additions and 0 deletions.
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)

0 comments on commit c2561fd

Please sign in to comment.