~fgimenez/+junk/ota-unit

« back to all changes in this revision

Viewing changes to ubuntu_ota_tests/tests/test_client.py

  • Committer: Federico Gimenez
  • Date: 2015-03-06 20:51:24 UTC
  • Revision ID: fgimenez@canonical.com-20150306205124-g0zunlzyp6zh808b
Back to the class approach, better for adding more methods for iteracting with the api

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from testtools import TestCase
2
 
from ubuntu_ota_tests import client
 
2
from ubuntu_ota_tests.client import SystemImageDBusClient
3
3
 
4
4
class TestClient(TestCase):
5
5
    """Tests for SystemImageDBusClient."""
6
6
 
7
 
    def test_get_system_image_iface(self):
 
7
    def setUp(self):
8
8
        class FakeDBusObject():
9
9
            def get_object(self, bus_name, path):
10
10
                assert bus_name == 'com.canonical.SystemImage'
11
11
                assert path == '/Service'
12
12
                return 'object_value'
 
13
        
13
14
        class FakeDBus():
14
15
            def SystemBus(self):
15
16
                return FakeDBusObject()
18
19
                assert iface == 'com.canonical.SystemImage'
19
20
                return 'iface_value'
20
21
 
21
 
        fake_dbus = FakeDBus()
22
 
        self.assertEqual(client.get_systemimage_iface(fake_dbus),
 
22
        super(TestClient, self).setUp()
 
23
        self.fake_dbus = FakeDBus()
 
24
    
 
25
    def test_get_system_image_iface(self):
 
26
        client = SystemImageDBusClient(self.fake_dbus)
 
27
        self.assertEqual(client.iface,
23
28
                         'iface_value')
24
29
 
25
30
    def test_get_current_build_number(self):
27
32
            def Information(self):
28
33
                return {'current_build_number': 'current_build_number_value'}
29
34
 
30
 
        fake_iface = FakeIface()
 
35
        client = SystemImageDBusClient(self.fake_dbus)
 
36
        client.iface = FakeIface()
31
37
        self.assertEqual(
32
 
            client.get_current_build_number(fake_iface),
 
38
            client.get_current_build_number(),
33
39
            'current_build_number_value')