forked from rc/aircox
write tests for streamer
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
from datetime import datetime, time
|
||||
import tzlocal
|
||||
|
||||
@@ -11,6 +13,9 @@ from aircox_streamer.connector import Connector
|
||||
local_tz = tzlocal.get_localzone()
|
||||
|
||||
|
||||
working_dir = os.path.join(os.path.dirname(__file__), "working_dir")
|
||||
|
||||
|
||||
class FakeSocket:
|
||||
FAILING_ADDRESS = -1
|
||||
"""Connect with this address fails."""
|
||||
@@ -62,7 +67,7 @@ class FakeSocket:
|
||||
@pytest.fixture
|
||||
def station():
|
||||
station = models.Station(
|
||||
name="test", path="/tmp", default=True, active=True
|
||||
name="test", path=working_dir, default=True, active=True
|
||||
)
|
||||
station.save()
|
||||
return station
|
||||
@@ -123,7 +128,7 @@ def sounds(program):
|
||||
# -- connectors
|
||||
@pytest.fixture
|
||||
def connector():
|
||||
obj = Connector("/tmp/test.sock")
|
||||
obj = Connector(os.path.join(working_dir, "test.sock"))
|
||||
obj.socket_class = FakeSocket
|
||||
yield obj
|
||||
obj.close()
|
||||
|
||||
Reference in New Issue
Block a user