~libertine-team/libertine/devel

« back to all changes in this revision

Viewing changes to tests/unit/test_libertine_gir.py

libertine-launch: refactored core components of application session management.

Approved by Christopher Townsend, Stephen M. Webb, Larry Price, Libertine CI Bot, Brandon Schaefer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2015 Canonical Ltd.
 
2
#
 
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.
 
6
#
 
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.
 
11
#
 
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/>.
 
14
 
 
15
import os
 
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
 
21
 
 
22
 
 
23
class TestLibertineGir(TestCase):
 
24
 
 
25
    def setUp(self):
 
26
        super(TestLibertineGir, self).setUp()
 
27
        self.cmake_source_dir = os.environ['LIBERTINE_DATA_DIR']
 
28
 
 
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()
 
32
 
 
33
            self.assertThat(containers[0], Equals('wily'))
 
34
            self.assertThat(containers[1], Equals('wily-2'))
 
35
 
 
36
    @skip("need to work around cached globals in glib")
 
37
    def test_container_path(self):
 
38
        container_id = 'wily'
 
39
        with patch.dict('os.environ', {'XDG_CACHE_HOME': self.cmake_source_dir + '/libertine-data'}):
 
40
            container_path = Libertine.container_path(container_id)
 
41
 
 
42
            self.assertThat(container_path, Equals(self.cmake_source_dir + '/libertine-data/libertine-container/wily/rootfs'))
 
43
 
 
44
    def test_container_home_path(self):
 
45
        container_id = 'wily'
 
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)
 
48
 
 
49
            self.assertThat(container_home_path, Equals(self.cmake_source_dir + '/libertine-home/libertine-container/user-data/wily'))
 
50
 
 
51
    def test_container_name(self):
 
52
        container_id = 'wily'
 
53
        with patch.dict('os.environ', {'XDG_DATA_HOME': self.cmake_source_dir + '/libertine-config'}):
 
54
            container_name = Libertine.container_name(container_id)
 
55
 
 
56
            self.assertThat(container_name, Equals("Ubuntu 'Wily Werewolf'"))
 
57
 
 
58
            container_id = 'wily-2'
 
59
            container_name = Libertine.container_name(container_id)
 
60
 
 
61
            self.assertThat(container_name, Equals("Ubuntu 'Wily Werewolf' (2)"))
 
62
 
 
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')
 
66
 
 
67
            self.assertThat(len(apps), Equals(0))