1
# Copyright 2015 Canonical Ltd.
3
# This program is free software: you can redistribute it and/or modify it
4
# under the terms of the GNU General Public License version 3, as published
5
# by the Free Software Foundation.
7
# This program is distributed in the hope that it will be useful, but
8
# WITHOUT ANY WARRANTY; without even the implied warranties of
9
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
10
# PURPOSE. See the GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License along
13
# with this program. If not, see <http://www.gnu.org/licenses/>.
16
from testtools import TestCase
17
from testtools.matchers import Equals
18
from gi.repository import Libertine
19
from unittest import skip
20
from unittest.mock import patch
23
class TestLibertineGir(TestCase):
26
super(TestLibertineGir, self).setUp()
27
self.cmake_source_dir = os.environ['LIBERTINE_DATA_DIR']
29
def test_list_containers(self):
30
with patch.dict('os.environ', {'XDG_DATA_HOME': self.cmake_source_dir + '/libertine-config'}):
31
containers = Libertine.list_containers()
33
self.assertThat(containers[0], Equals('wily'))
34
self.assertThat(containers[1], Equals('wily-2'))
36
@skip("need to work around cached globals in glib")
37
def test_container_path(self):
39
with patch.dict('os.environ', {'XDG_CACHE_HOME': self.cmake_source_dir + '/libertine-data'}):
40
container_path = Libertine.container_path(container_id)
42
self.assertThat(container_path, Equals(self.cmake_source_dir + '/libertine-data/libertine-container/wily/rootfs'))
44
def test_container_home_path(self):
46
with patch.dict('os.environ', {'XDG_DATA_HOME': self.cmake_source_dir + '/libertine-home'}):
47
container_home_path = Libertine.container_home_path(container_id)
49
self.assertThat(container_home_path, Equals(self.cmake_source_dir + '/libertine-home/libertine-container/user-data/wily'))
51
def test_container_name(self):
53
with patch.dict('os.environ', {'XDG_DATA_HOME': self.cmake_source_dir + '/libertine-config'}):
54
container_name = Libertine.container_name(container_id)
56
self.assertThat(container_name, Equals("Ubuntu 'Wily Werewolf'"))
58
container_id = 'wily-2'
59
container_name = Libertine.container_name(container_id)
61
self.assertThat(container_name, Equals("Ubuntu 'Wily Werewolf' (2)"))
63
def test_list_apps_for_container(self):
64
with patch.dict('os.environ', {'XDG_DATA_HOME': self.cmake_source_dir + '/libertine-config'}):
65
apps = Libertine.list_apps_for_container('wily')
67
self.assertThat(len(apps), Equals(0))