-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocks.py
35 lines (26 loc) · 945 Bytes
/
mocks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Mocks for sensor and database client, for testing"""
# Mock database
def init_db(db_name, host='localhost', port=8086):
"""NOOP to initialize the database client"""
return MockDBClient(db_name)
class MockDBClient:
def __init__(self, db_name):
self.db_name = db_name
def write_points(self, sensor_data):
"""Print sensor data to stdout. Always returns True"""
print(sensor_data)
return True
# Mock sensor
def init_sensor(sensor_id, sensor_location):
"""Return a mock sensor object"""
return MockSensor(sensor_id, sensor_location)
class MockSensor:
sensor_type = "MockSensor"
temperature = 21.12
humidity = 51.50
pressure = 1010.1010
def __init__(self, sensor_id, sensor_location):
self.sensor_id = sensor_id
self.sensor_location = sensor_location
def read_data(self):
"""NOOP: Read data from the sensor into our class variables"""