mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-17 13:31:29 +00:00
Introduce BOOTTEST_FETCH configuration option for enabling/disabling TouchManifest auto-fetching feature, for faster and isolated tests.
This commit is contained in:
parent
8d0cc0f292
commit
37bd9924f7
10
boottest.py
10
boottest.py
@ -50,11 +50,12 @@ class TouchManifest(object):
|
|||||||
with open(self.path, 'w') as fp:
|
with open(self.path, 'w') as fp:
|
||||||
fp.write(response.read())
|
fp.write(response.read())
|
||||||
|
|
||||||
def __init__(self, distribution, series):
|
def __init__(self, distribution, series, fetch=True):
|
||||||
self.path = "boottest/images/{}/{}/manifest".format(
|
self.path = "boottest/images/{}/{}/manifest".format(
|
||||||
distribution, series)
|
distribution, series)
|
||||||
|
|
||||||
self.__fetch_manifest(distribution, series)
|
if fetch:
|
||||||
|
self.__fetch_manifest(distribution, series)
|
||||||
|
|
||||||
self._manifest = self._load()
|
self._manifest = self._load()
|
||||||
|
|
||||||
@ -102,7 +103,10 @@ class BootTest(object):
|
|||||||
self.distribution = distribution
|
self.distribution = distribution
|
||||||
self.series = series
|
self.series = series
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
self.phone_manifest = TouchManifest(self.distribution, self.series)
|
manifest_fetch = getattr(
|
||||||
|
self.britney.options, "boottest_fetch", "no") == "yes"
|
||||||
|
self.phone_manifest = TouchManifest(
|
||||||
|
self.distribution, self.series, fetch=manifest_fetch)
|
||||||
|
|
||||||
def _get_status(self, name, version):
|
def _get_status(self, name, version):
|
||||||
"""Return the current boottest status.
|
"""Return the current boottest status.
|
||||||
|
@ -69,3 +69,4 @@ ADT_ARCHES = amd64 i386
|
|||||||
BOOTTEST_ARCHES = armhf
|
BOOTTEST_ARCHES = armhf
|
||||||
BOOTTEST_ENABLE = yes
|
BOOTTEST_ENABLE = yes
|
||||||
BOOTTEST_DEBUG = yes
|
BOOTTEST_DEBUG = yes
|
||||||
|
BOOTTEST_FETCH = yes
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
import mock
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
@ -30,6 +31,16 @@ def create_manifest(manifest_dir, lines):
|
|||||||
fd.write('\n'.join(lines))
|
fd.write('\n'.join(lines))
|
||||||
|
|
||||||
|
|
||||||
|
class FakeResponse(object):
|
||||||
|
|
||||||
|
def __init__(self, code=404, content=''):
|
||||||
|
self.code = code
|
||||||
|
self.content = content
|
||||||
|
|
||||||
|
def read(self):
|
||||||
|
return self.content
|
||||||
|
|
||||||
|
|
||||||
class TestTouchManifest(unittest.TestCase):
|
class TestTouchManifest(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -39,6 +50,10 @@ class TestTouchManifest(unittest.TestCase):
|
|||||||
self.imagesdir = os.path.join(self.path, 'boottest/images')
|
self.imagesdir = os.path.join(self.path, 'boottest/images')
|
||||||
os.makedirs(self.imagesdir)
|
os.makedirs(self.imagesdir)
|
||||||
self.addCleanup(shutil.rmtree, self.path)
|
self.addCleanup(shutil.rmtree, self.path)
|
||||||
|
_p = mock.patch('urllib.urlopen')
|
||||||
|
self.mocked_urlopen = _p.start()
|
||||||
|
self.mocked_urlopen.side_effect = [FakeResponse(code=404),]
|
||||||
|
self.addCleanup(_p.stop)
|
||||||
|
|
||||||
def test_missing(self):
|
def test_missing(self):
|
||||||
# Missing manifest file silently results in empty contents.
|
# Missing manifest file silently results in empty contents.
|
||||||
@ -48,9 +63,18 @@ class TestTouchManifest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_fetch(self):
|
def test_fetch(self):
|
||||||
# Missing manifest file is fetched dynamically
|
# Missing manifest file is fetched dynamically
|
||||||
|
self.mocked_urlopen.side_effect = [
|
||||||
|
FakeResponse(code=200, content='foo 1.0'),
|
||||||
|
]
|
||||||
manifest = TouchManifest('ubuntu-touch', 'vivid')
|
manifest = TouchManifest('ubuntu-touch', 'vivid')
|
||||||
self.assertNotEqual([], manifest._manifest)
|
self.assertNotEqual([], manifest._manifest)
|
||||||
|
|
||||||
|
def test_fetch_disabled(self):
|
||||||
|
# Manifest auto-fetching can be disabled.
|
||||||
|
manifest = TouchManifest('ubuntu-touch', 'vivid', fetch=False)
|
||||||
|
self.mocked_urlopen.assert_not_called()
|
||||||
|
self.assertEqual([], manifest._manifest)
|
||||||
|
|
||||||
def test_fetch_fails(self):
|
def test_fetch_fails(self):
|
||||||
distribution = 'fake'
|
distribution = 'fake'
|
||||||
series = 'fake'
|
series = 'fake'
|
||||||
@ -98,6 +122,9 @@ class TestBoottestEnd2End(TestBase):
|
|||||||
self.old_config = fp.read()
|
self.old_config = fp.read()
|
||||||
config = self.old_config.replace(
|
config = self.old_config.replace(
|
||||||
'ADT_ENABLE = yes', 'ADT_ENABLE = no')
|
'ADT_ENABLE = yes', 'ADT_ENABLE = no')
|
||||||
|
# Disable TouchManifest auto-fetching.
|
||||||
|
config = config.replace(
|
||||||
|
'BOOTTEST_FETCH = yes', 'BOOTTEST_FETCH = no')
|
||||||
with open(self.britney_conf, 'w') as fp:
|
with open(self.britney_conf, 'w') as fp:
|
||||||
fp.write(config)
|
fp.write(config)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user