# Copyright (c) 2015 Canonical Ltd
#
#    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.

import os

import unittest

from pylxd import api

class LXDFunctionalTestHost(unittest.TestCase):
    def setUp(self):
        super(LXDFunctionalTestHost, self).setUp()
        self.lxd = api.API()

    def test_host_ping(self):
        self.assertTrue(self.lxd.host_ping())

    def test_host_info(self):
        host = self.lxd.host_info()
        self.assertIsInstance(host, dict)

        self.assertEqual(host['lxd_driver'], 'lxc')
        self.assertEqual(host['lxd_api_compat_level'], 1)
        kernel_version = os.uname()[2]
        self.assertEqual(host['kernel_version'], kernel_version)

    def test_get_lxd_compat(self):
        self.assertEqual(1, self.lxd.get_lxd_api_compat())

    def test_get_lxd_host_trust(self):
        self.assertTrue(self.lxd.get_lxd_host_trust())

@@ -612,16 +612,34 @@
 mport os
+%0Aimport subprocess
 %0A%0Aimport
@@ -1408,12 +1408,757 @@
 st_trust())%0A
+%0A    def test_get_lxd_backing_fs(self):%0A        df_output = %5B%0A            s.split() for s in os.popen(%22df -TP /var/lib/lxd%22).%5C%0A                    read().splitlines()%5D%0A        self.assertEquals(df_output%5B1%5D%5B1%5D,%0A                         self.lxd.get_lxd_backing_fs(data=None))%0A%0A    def test_get_lxd_driver(self):%0A        self.assertEqual('lxc', self.lxd.get_lxd_driver(data=None))%0A%0A    def test_get_lxc_version(self):%0A        process = subprocess.Popen(%5B'lxc-info', '--version'%5D, stdout=subprocess.PIPE)%0A        version = process.communicate()%5B0%5D%0A        self.assertEqual(version.rstrip(), self.lxd.get_lxc_version(data=None))%0A%0A    def test_get_kernel_version(self):%0A        self.assertEqual(os.uname()%5B2%5D, self.lxd.get_kernel_version(data=None))

Add more hosts tests.