-
Notifications
You must be signed in to change notification settings - Fork 2
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
598002d
commit 4ad4991
Showing
3 changed files
with
114 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import datetime | ||
|
||
import pytest | ||
from freezegun import freeze_time | ||
|
||
import pygmc | ||
|
||
from ..mocks import MockConnection | ||
|
||
|
||
@freeze_time(datetime.datetime(2024, 1, 8, 17, 54, 57)) | ||
def test_set_datetime_now(): | ||
"""Test set_datetime issues cmd of current datetime""" | ||
actions_cmd_response_map = { | ||
# datetime.datetime(2024, 1, 8, 17, 54, 57, 662848) | ||
b"<SETDATETIME\x18\x01\x08\x1169>>": b"\xaa", | ||
} | ||
actions_conn = MockConnection(actions_cmd_response_map) | ||
gc_rfc1201 = pygmc.devices.DeviceRFC1201(actions_conn) | ||
gc_rfc1201.set_datetime() | ||
assert actions_conn.get_cmd_calls(b"<SETDATETIME\x18\x01\x08\x1169>>") == 1 | ||
|
||
|
||
def test_raises_set_datetime(): | ||
"""Test set_datetime raises RuntimeError if response if wrong""" | ||
actions_cmd_response_map = { | ||
# datetime.datetime(2024, 1, 8, 17, 54, 57, 662848) | ||
b"<SETDATETIME\x18\x01\x08\x1169>>": b"\xab", # Note the last char! | ||
} | ||
actions_conn = MockConnection(actions_cmd_response_map) | ||
gc_rfc1201 = pygmc.devices.DeviceRFC1201(actions_conn) | ||
dt = datetime.datetime(2024, 1, 8, 17, 54, 57) | ||
with pytest.raises(RuntimeError): | ||
# This is the main test | ||
gc_rfc1201.set_datetime(datetime_=dt) | ||
|
||
# This is GRC that the cmd was even called | ||
assert actions_conn.get_cmd_calls(b"<SETDATETIME\x18\x01\x08\x1169>>") == 1 |
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,38 @@ | ||
import datetime | ||
|
||
import pytest | ||
from freezegun import freeze_time | ||
|
||
import pygmc | ||
|
||
from ..mocks import MockConnection | ||
|
||
|
||
@freeze_time(datetime.datetime(2024, 1, 8, 17, 54, 57)) | ||
def test_set_datetime_now(): | ||
"""Test set_datetime issues cmd of current datetime""" | ||
actions_cmd_response_map = { | ||
# datetime.datetime(2024, 1, 8, 17, 54, 57, 662848) | ||
b"<SETDATETIME\x18\x01\x08\x1169>>": b"\xaa", | ||
} | ||
actions_conn = MockConnection(actions_cmd_response_map) | ||
gc_rfc1801 = pygmc.devices.DeviceRFC1801(actions_conn) | ||
gc_rfc1801.set_datetime() | ||
assert actions_conn.get_cmd_calls(b"<SETDATETIME\x18\x01\x08\x1169>>") == 1 | ||
|
||
|
||
def test_raises_set_datetime(): | ||
"""Test set_datetime raises RuntimeError if response if wrong""" | ||
actions_cmd_response_map = { | ||
# datetime.datetime(2024, 1, 8, 17, 54, 57, 662848) | ||
b"<SETDATETIME\x18\x01\x08\x1169>>": b"\xab", # Note the last char! | ||
} | ||
actions_conn = MockConnection(actions_cmd_response_map) | ||
gc_rfc1801 = pygmc.devices.DeviceRFC1801(actions_conn) | ||
dt = datetime.datetime(2024, 1, 8, 17, 54, 57) | ||
with pytest.raises(RuntimeError): | ||
# This is the main test | ||
gc_rfc1801.set_datetime(datetime_=dt) | ||
|
||
# This is GRC that the cmd was even called | ||
assert actions_conn.get_cmd_calls(b"<SETDATETIME\x18\x01\x08\x1169>>") == 1 |
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,38 @@ | ||
import datetime | ||
|
||
import pytest | ||
from freezegun import freeze_time | ||
|
||
import pygmc | ||
|
||
from ..mocks import MockConnection | ||
|
||
|
||
@freeze_time(datetime.datetime(2024, 1, 8, 17, 54, 57)) | ||
def test_set_datetime_now(): | ||
"""Test set_datetime issues cmd of current datetime""" | ||
actions_cmd_response_map = { | ||
# datetime.datetime(2024, 1, 8, 17, 54, 57, 662848) | ||
b"<SETDATETIME\x18\x01\x08\x1169>>": b"\xaa", | ||
} | ||
actions_conn = MockConnection(actions_cmd_response_map) | ||
gc_rfc404 = pygmc.devices.DeviceSpec404(actions_conn) | ||
gc_rfc404.set_datetime() | ||
assert actions_conn.get_cmd_calls(b"<SETDATETIME\x18\x01\x08\x1169>>") == 1 | ||
|
||
|
||
def test_raises_set_datetime(): | ||
"""Test set_datetime raises RuntimeError if response if wrong""" | ||
actions_cmd_response_map = { | ||
# datetime.datetime(2024, 1, 8, 17, 54, 57, 662848) | ||
b"<SETDATETIME\x18\x01\x08\x1169>>": b"\xab", # Note the last char! | ||
} | ||
actions_conn = MockConnection(actions_cmd_response_map) | ||
gc_rfc404 = pygmc.devices.DeviceSpec404(actions_conn) | ||
dt = datetime.datetime(2024, 1, 8, 17, 54, 57) | ||
with pytest.raises(RuntimeError): | ||
# This is the main test | ||
gc_rfc404.set_datetime(datetime_=dt) | ||
|
||
# This is GRC that the cmd was even called | ||
assert actions_conn.get_cmd_calls(b"<SETDATETIME\x18\x01\x08\x1169>>") == 1 |