Adding changes done in PR#18 (Removed unused imports and code)
-from foglamp.coap.uri_handlers.sensor_values import SensorValues
-from foglamp.coap.uri_handlers.sensor_values import SensorValues
-from foglamp.coap.uri_handlers.sensor_values import __tbl__
-from foglamp.coap.uri_handlers.sensor_values import *
-import sqlalchemy
-import unittest
from unittest import mock
from unittest.mock import MagicMock
+
from cbor2 import dumps
+from foglamp.coap.uri_handlers.sensor_values import SensorValues
+import asyncio
+
def AsyncMock(*args, **kwargs):
m = mock.MagicMock(*args, **kwargs)
@@ -17,6 +15,7 @@ def AsyncMock(*args, **kwargs):
mock_coro.mock = m
return mock_coro
+
class MagicMockConnection(MagicMock):
execute = AsyncMock()
@@ -29,6 +28,7 @@ class AcquireContextManager(MagicMock):
async def __aexit__(self, exc_type, exc_val, exc_tb):
pass
+
class MagicMockEngine(MagicMock):
acquire = AcquireContextManager()
@@ -41,17 +41,15 @@ class CreateEngineContextManager(MagicMock):
async def __aexit__(self, exc_type, exc_val, exc_tb):
pass
-class FakeConfig(MagicMock):
- db_conn_str = "fake_connection"
def _run(coro):
return asyncio.get_event_loop().run_until_complete(coro)
+
# http://docs.sqlalchemy.org/en/latest/core/dml.html
-class TestSensorValues():
+class TestSensorValues:
def test_render_post(self, mocker):
mocker.patch('aiopg.sa.create_engine', return_value=CreateEngineContextManager())
- mocker.patch('foglamp.configurator.Configurator.__init__', return_value=None)
# test_patch3.return_value = values(data='', key='')
sv = SensorValues()
request = MagicMock()
@@ -61,6 +59,3 @@ class TestSensorValues():
assert returnval is not None
# assert sqlalchemy.Table.insert.mock.assert_called_once_with('blu')
# assert MagicMockConnection.execute.mock.assert_called_once_with('blu')
-
-
-
