mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-03-12 03:41:08 +00:00
boottest - Fetch manifests dynamically but use cached manifests if the fetch fails
This commit is contained in:
parent
c340a46e7a
commit
2e5084ee79
22
boottest.py
22
boottest.py
@ -12,6 +12,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
import os
|
||||
import urllib
|
||||
|
||||
from consts import BINARIES
|
||||
|
||||
@ -36,9 +37,25 @@ class TouchManifest(object):
|
||||
|
||||
"""
|
||||
|
||||
def __fetch_manifest(self, distribution, series):
|
||||
url = "http://cdimage.ubuntu.com/{}/daily-preinstalled/" \
|
||||
"pending/{}-preinstalled-touch-armhf.manifest".format(
|
||||
distribution, series
|
||||
)
|
||||
response = urllib.urlopen(url)
|
||||
# Only [re]create the manifest file if one was successfully downloaded
|
||||
# this allows for an existing image to be used if the download fails.
|
||||
if response.code == 200:
|
||||
os.makedirs(os.path.dirname(self.path))
|
||||
with open(self.path, 'w') as fp:
|
||||
fp.write(response.read())
|
||||
|
||||
def __init__(self, distribution, series):
|
||||
self.path = 'boottest/images/{}/{}/manifest'.format(
|
||||
self.path = "boottest/images/{}/{}/manifest".format(
|
||||
distribution, series)
|
||||
|
||||
self.__fetch_manifest(distribution, series)
|
||||
|
||||
self._manifest = self._load()
|
||||
|
||||
def _load(self):
|
||||
@ -49,6 +66,9 @@ class TouchManifest(object):
|
||||
|
||||
with open(self.path) as fd:
|
||||
for line in fd.readlines():
|
||||
# skip headers and metadata
|
||||
if 'DOCTYPE' in line:
|
||||
continue
|
||||
name, version = line.split()
|
||||
name = name.split(':')[0]
|
||||
if name == 'click':
|
||||
|
@ -46,6 +46,23 @@ class TestTouchManifest(unittest.TestCase):
|
||||
self.assertEqual([], manifest._manifest)
|
||||
self.assertNotIn('foo', manifest)
|
||||
|
||||
def test_fetch(self):
|
||||
# Missing manifest file is fetched dynamically
|
||||
manifest = TouchManifest('ubuntu-touch', 'vivid')
|
||||
self.assertNotEqual([], manifest._manifest)
|
||||
|
||||
def test_fetch_fails(self):
|
||||
distribution = 'fake'
|
||||
series = 'fake'
|
||||
manifest_dir = os.path.join(self.imagesdir, distribution, series)
|
||||
manifest_lines = [
|
||||
'foo:armhf 1~beta1',
|
||||
]
|
||||
create_manifest(manifest_dir, manifest_lines)
|
||||
manifest = TouchManifest(distribution, series)
|
||||
self.assertEqual(1, len(manifest._manifest))
|
||||
self.assertIn('foo', manifest)
|
||||
|
||||
def test_simple(self):
|
||||
# Existing manifest file allows callsites to properly check presence.
|
||||
manifest_dir = os.path.join(self.imagesdir, 'ubuntu/vivid')
|
||||
|
Loading…
x
Reference in New Issue
Block a user