# Path: controller/sensor.py
# class MovingAverage:
# 
#     def __init__(self, maxlen):
#         self.__data = collections.deque(maxlen=maxlen)
# 
#     def clear(self):
#         self.__data.clear()
# 
#     def push(self, value):
#         self.__data.append(value)
# 
#     def all(self):
#         return list(self.__data)
# 
#     def mean(self):
#         return statistics.mean(self.__data) if self.__data else None


import pytest
from controller.sensor import MovingAverage
    from controller.sensor import TemperatureReader
# Poupool - swimming pool control software
# Copyright (C) 2020 Cyril Jaquier
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.



@pytest.fixture
def temperature_reader(mocker):
    reader = TemperatureReader({})
    return reader


class TestTemperatureReader:

    def test_slope_empty(self, mocker, temperature_reader):
        mock_values = mocker.patch(
            "controller.sensor.TemperatureReader.values", new_callable=mocker.PropertyMock)

# Path: controller/sensor.py
# class MovingAverage:
# 
#     def __init__(self, maxlen):
#         self.__data = collections.deque(maxlen=maxlen)
# 
#     def clear(self):
#         self.__data.clear()
# 
#     def push(self, value):
#         self.__data.append(value)
# 
#     def all(self):
#         return list(self.__data)
# 
#     def mean(self):
#         return statistics.mean(self.__data) if self.__data else None


# Path: test/test_sensor.py
import pytest
from controller.sensor import MovingAverage
    from controller.sensor import TemperatureReader

# Poupool - swimming pool control software
# Copyright (C) 2020 Cyril Jaquier
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.



@pytest.fixture
def temperature_reader(mocker):
    reader = TemperatureReader({})
    return reader


class TestTemperatureReader:

    def test_slope_empty(self, mocker, temperature_reader):
        mock_values = mocker.patch(
            "controller.sensor.TemperatureReader.values", new_callable=mocker.PropertyMock)

        mock_values.return_value = {"pool": MovingAverage(10)}