~vila/ubuntu-test-cases/retry-apt-get-update

« back to all changes in this revision

Viewing changes to tests/click_image_tests/check_preinstalled_list/check_preinstalled_list.py

  • Committer: Leo Arias
  • Date: 2014-11-10 19:28:56 UTC
  • mfrom: (345 touch)
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: leo.arias@canonical.com-20141110192856-rgpksx9n9j0b39yl
Merged with the touch branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python3
 
2
# Copyright (C) 2013 Canonical Ltd.
 
3
# Author: Sergio Schvezov <sergio.schvezov@canonical.com>
 
4
 
 
5
# This program is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; version 3 of the License.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
import subprocess
 
18
import unittest
 
19
import urllib.request
 
20
 
 
21
 
 
22
click_list_url = \
 
23
    'http://people.canonical.com/~ubuntu-archive/click_packages/click_list'
 
24
 
 
25
 
 
26
def get_install_list():
 
27
    request = urllib.request.urlopen(click_list_url).read().decode('utf-8')
 
28
    click_files = [x for x in request.split('\n') if x]
 
29
    click_apps = {}
 
30
    for entry in click_files:
 
31
        entry_parts = entry.split('_')
 
32
        click_apps[entry_parts[0]] = entry_parts[1]
 
33
    return click_apps
 
34
 
 
35
 
 
36
def get_image_list():
 
37
    click_list = subprocess.check_output(
 
38
        ['adb', 'shell', 'sudo', '-iu', 'phablet',
 
39
         'click', 'list']).decode('utf-8').split('\n')
 
40
    click_entries = [x for x in click_list if x]
 
41
    click_apps = {}
 
42
    for entry in click_entries:
 
43
        entry_parts = entry.split('\t')
 
44
        click_apps[entry_parts[0]] = entry_parts[1].strip()
 
45
    return click_apps
 
46
 
 
47
 
 
48
class ClickPreinstalled(unittest.TestCase):
 
49
 
 
50
    def setUp(self):
 
51
        self.image_list = get_image_list()
 
52
        self.install_list = get_install_list()
 
53
        print('Search for {} on image'.format(list(self.install_list.keys())))
 
54
 
 
55
    def testPreinstalled(self):
 
56
        for entry in self.install_list:
 
57
            self.assertIn(entry, list(self.image_list.keys()))
 
58
 
 
59
 
 
60
if __name__ == '__main__':
 
61
    unittest.main()