26
26
from datetime import timedelta
27
from pkg_resources import resource_filename
27
28
from systemimage.config import Configuration, config
28
29
from systemimage.reboot import Reboot
29
30
from systemimage.scores import WeightedScorer
30
from systemimage.tests.helpers import test_data_path, testable_configuration
31
from systemimage.testing.helpers import test_data_path, testable_configuration
31
32
from systemimage.tests.reboot import TestableReboot
34
35
class TestConfiguration(unittest.TestCase):
35
36
def test_defaults(self):
37
default_ini = resource_filename('systemimage.data', 'client.ini')
36
38
config = Configuration()
39
config.load(default_ini)
38
self.assertEqual(config.service.base, 'phablet.stgraber.org')
41
self.assertEqual(config.service.base, 'system-image.ubuntu.com')
39
42
self.assertEqual(config.service.http_base,
40
'http://phablet.stgraber.org')
43
'http://system-image.ubuntu.com')
41
44
self.assertEqual(config.service.https_base,
42
'https://phablet.stgraber.org')
45
'https://system-image.ubuntu.com')
44
self.assertEqual(config.system.tempdir, '/tmp/phablet')
45
self.assertEqual(config.system.channel, 'stable')
46
self.assertEqual(config.system.device, 'nexus7')
47
self.assertEqual(config.system.tempdir, '/tmp/system-image')
48
self.assertEqual(config.system.channel, 'daily')
49
self.assertEqual(config.system.device, 'mako')
48
51
self.assertEqual(config.hooks.scorer, WeightedScorer)
49
52
self.assertEqual(config.hooks.reboot, Reboot)
51
54
self.assertEqual(config.gpg.archive_master,
52
'/etc/image-upgrades-resolver/archive-master.tar.xz')
55
'/etc/system-image/archive-master.tar.xz')
54
57
config.gpg.image_master,
55
'/var/lib/image-upgrades-resolver/keyrings/image-master.tar.xz')
58
'/var/lib/system-image/keyrings/image-master.tar.xz')
57
60
config.gpg.image_signing,
58
'/var/lib/image-upgrades-resolver/keyrings/image-signing.tar.xz')
61
'/var/lib/system-image/keyrings/image-signing.tar.xz')
60
63
config.gpg.device_signing,
61
'/var/lib/image-upgrades-resolver/keyrings/device-signing.tar.xz')
64
'/var/lib/system-image/keyrings/device-signing.tar.xz')
63
66
self.assertEqual(config.updater.cache_partition,
64
67
'/android/cache/recovery')
65
68
self.assertEqual(config.updater.data_partition,
66
'/var/lib/image-upgrades-resolver/')
69
'/var/lib/system-image')
68
71
def test_basic_ini_file(self):
69
72
# Read a basic .ini file and check that the various attributes and