# Copyright 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Test 'stratisd'.
"""

import time
import unittest

from stratis_cli._constants import TOP_OBJECT

from stratis_cli._dbus import Manager
from stratis_cli._dbus import get_object

from ._misc import Service


class StratisTestCase(unittest.TestCase):
    """
    Test meta information about stratisd.
    """

    def setUp(self):
        """
        Start the stratisd daemon with the simulator.
        """
        self._service = Service()
        self._service.setUp()

    def tearDown(self):
        """
        Stop the stratisd simulator and daemon.
        """
        self._service.tearDown()

    def testStratisVersion(self):
        """
        Getting version should just succeed.
        """
        time.sleep(1)
        result = Manager(get_object(TOP_OBJECT)).Version
        self.assertEqual(type(result), str)

    @unittest.expectedFailure
    def testStratisLogLevel(self):
        """
        Getting log level should just succeed.
        """
        time.sleep(1)
        result = Manager(get_object(TOP_OBJECT)).LogLevel
        self.assertEqual(type(result), int)

@@ -1045,16 +1045,38 @@
 .setUp()
+%0A        time.sleep(1)
 %0A%0A    de
@@ -1302,38 +1302,16 @@
     %22%22%22%0A
-        time.sleep(1)%0A
         
@@ -1540,38 +1540,16 @@
     %22%22%22%0A
-        time.sleep(1)%0A
         
@@ -1598,16 +1598,16 @@
 ogLevel%0A
-
         
@@ -1642,8 +1642,216 @@
 ), int)%0A
+%0A    def testStratisLogLevel(self):%0A        %22%22%22%0A        Getting log level property does get a value.%0A        %22%22%22%0A        result = Manager(get_object(TOP_OBJECT)).LogLevel%0A        self.assertIsNotNone(result)%0A

Improve stratis testing a bit.