~sil2100/ubuntu-system-image/server-tags

« back to all changes in this revision

Viewing changes to bin/tests/test_tag-image.py

  • Committer: Łukasz 'sil2100' Zemczak
  • Date: 2015-11-06 18:27:26 UTC
  • Revision ID: lukasz.zemczak@canonical.com-20151106182726-wolnd4yypjb8te3x
Finish up writing the basic new troublesome tests. One of them is skipped because the current implementation of deltabase decisions is wrong (and was wrong since the beginning), so writing tests just to make the unit tests happy would be pointless.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
 
3
 
# Copyright (C) 2015 Canonical Ltd.
4
 
# Author: Łukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>
5
 
 
6
 
# This program is free software: you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation; version 3 of the License.
9
 
#
10
 
# This program is distributed in the hope that it will be useful,
11
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
# GNU General Public License for more details.
14
 
#
15
 
# You should have received a copy of the GNU General Public License
16
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
 
18
 
import os
19
 
import imp
20
 
import shutil
21
 
import stat
22
 
import subprocess
23
 
import tarfile
24
 
import tempfile
25
 
import unittest
26
 
 
27
 
from systemimage.helpers import chdir
28
 
from systemimage.testing.helpers import HAS_TEST_KEYS, MISSING_KEYS_WARNING
29
 
 
30
 
 
31
 
class TagImageScriptTests(unittest.TestCase):
32
 
    def setUp(self):
33
 
        bin_dir = os.path.dirname(os.path.dirname(__file__))
34
 
        self.script_name = "tag-image"
35
 
        self.script = imp.load_source(
36
 
            self.script_name,
37
 
            os.path.join(bin_dir, self.script_name))
38
 
 
39
 
    def test_set_tag(self):
40
 
        """Set a basic tag."""
41
 
        version_detail_list = [
42
 
            "device=20150821-736d127",
43
 
            "custom=20150925-901-35-40-vivid",
44
 
            "keyring=archive-master",
45
 
            "version=6"]
46
 
        self.script.set_tag(version_detail_list, "OTA-x")
47
 
        self.assertTrue("tag=OTA-x" in version_detail_list)
48
 
        size = len([x for x in version_detail_list if x.startswith("tag=")])
49
 
        self.assertEqual(size, 1)
50
 
 
51
 
    def test_set_tag_rewrite(self):
52
 
        """Make sure tags can be rewritten."""
53
 
        version_detail_list = [
54
 
            "device=20150821-736d127",
55
 
            "custom=20150925-901-35-40-vivid",
56
 
            "tag=something",
57
 
            "keyring=archive-master",
58
 
            "tag=different",
59
 
            "version=6"]
60
 
        self.script.set_tag(version_detail_list, "OTA-x")
61
 
        self.assertTrue("tag=OTA-x" in version_detail_list)
62
 
        size = len([x for x in version_detail_list if x.startswith("tag=")])
63
 
        self.assertEqual(size, 1)
64
 
 
65
 
#    @unittest.skipUnless(HAS_TEST_KEYS, MISSING_KEYS_WARNING)
66
 
#    def test_channels(self):
67
 
        
 
 
b'\\ No newline at end of file'