Skip to content

Commit

Permalink
Consolidate tests to eliminate a fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 committed May 22, 2024
1 parent 0711181 commit e6f2a90
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions clickplc/tests/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ def plc_driver():
return ClickPLC('fake ip')


@pytest.fixture
def tagged_driver():
"""Confirm the driver correctly initializes with a good tags file."""
return ClickPLC('fake ip', 'clickplc/tests/plc_tags.csv')


@pytest.fixture
Expand Down Expand Up @@ -66,10 +62,6 @@ def test_driver_cli_tags(capsys):
command_line(['fakeip', 'tags', 'bogus'])


def test_get_tags(tagged_driver, expected_tags):
"""Confirm that the driver returns correct values on get() calls."""
assert expected_tags == tagged_driver.get_tags()


def test_unsupported_tags():
"""Confirm the driver detects an improper tags file."""
Expand All @@ -78,12 +70,13 @@ def test_unsupported_tags():


@pytest.mark.asyncio
async def test_tagged_driver(tagged_driver, expected_tags):
async def test_tagged_driver(expected_tags):
"""Test a roundtrip with the driver using a tags file."""
await tagged_driver.set('VAH_101_OK', True)
state = await tagged_driver.get()
assert state.get('VAH_101_OK')
assert expected_tags.keys() == state.keys()
async with ClickPLC('fakeip', 'clickplc/tests/plc_tags.csv') as tagged_driver:
await tagged_driver.set('VAH_101_OK', True)
state = await tagged_driver.get()
assert state.get('VAH_101_OK')
assert expected_tags == tagged_driver.get_tags()


@pytest.mark.asyncio
Expand Down

0 comments on commit e6f2a90

Please sign in to comment.