#
# Aura Engine API (https://gitlab.servus.at/aura/engine-api)
#
# Copyright (C) 2020 - The Aura Engine Team.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from __future__ import absolute_import

from flask import json
from six import BytesIO

from src.rest.models.clock_info import ClockInfo  # noqa: E501
org.joda.time.*  # noqa: E501
from src.rest.models.health_info import HealthInfo  # noqa: E501
from src.rest.models.play_log_entry import PlayLogEntry  # noqa: E501
from src.rest.models.status_entry import StatusEntry  # noqa: E501
from src.rest.test import BaseTestCase


class TestInternalController(BaseTestCase):
    """InternalController integration test stubs"""

    def test_activate_engine(self):
        """Test case for activate_engine

        Set active engine
        """
        response = self.client.open(
            '/api/v1/engine/{engine_number}/activate'.format(engine_number=2),
            method='PUT')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

    def test_add_playlog(self):
        """Test case for add_playlog

        Adds an entry to the playlog
        """
        response = self.client.open(
            '/api/v1/playlog/add',
            method='POST')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

    def test_clock_info(self):
        """Test case for clock_info

        Get all information to display the studio clock
        """
        response = self.client.open(
            '/api/v1/clock',
            method='GET')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

    def test_get_active_engine(self):
        """Test case for get_active_engine

        Get active engine
        """
        response = self.client.open(
            '/api/v1/engine/current',
            method='GET')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

    def test_get_engine_health(self):
        """Test case for get_engine_health

        Get most recent health info
        """
        response = self.client.open(
            '/api/v1/engine/{engine_number}/health'.format(engine_number=2),
            method='GET')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

    def test_get_report(self):
        """Test case for get_report

        Report for one month
        """
        response = self.client.open(
            '/api/v1/playlog/report/{year_month}'.format(year_month='year_month_example'),
            method='GET')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

    def test_list_playlog(self):
        """Test case for list_playlog

        List tracks in the play-log since the given timestamp
        """
        query_string = [('page', 56),
                        ('limit', 200)]
        response = self.client.open(
            '/api/v1/playlog/since/{date_time}'.format(date_time='2013-10-20T19:20:30+01:00'),
            method='GET',
            query_string=query_string)
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

    def test_log_engine_health(self):
        """Test case for log_engine_health

        Log health info
        """
        response = self.client.open(
            '/api/v1/engine/{engine_number}/health'.format(engine_number=2),
            method='POST')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))


if __name__ == '__main__':
    import unittest
    unittest.main()