1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
# Autopilot Functional Test Tool
4
# Copyright (C) 2012-2013 Canonical
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, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
from testtools import TestCase
22
from testtools.matchers import Equals, Not, NotEquals
23
from autopilot.introspection.backends import DBusAddress
25
class DBusAddressTests(TestCase):
27
def test_can_construct(self):
29
addr = DBusAddress(fake_bus, "conn", "path")
31
def test_can_store_address_in_dictionary(self):
33
addr = DBusAddress(fake_bus, "conn", "path")
36
def test_equality_operator(self):
38
addr1 = DBusAddress(fake_bus, "conn", "path")
40
self.assertThat(addr1, Equals(DBusAddress(fake_bus, "conn", "path")))
41
self.assertThat(addr1, Not(Equals(DBusAddress(fake_bus, "conn", "new_path"))))
42
self.assertThat(addr1, Not(Equals(DBusAddress(fake_bus, "conn2", "path"))))
43
self.assertThat(addr1, Not(Equals(DBusAddress(object(), "conn", "path"))))
45
def test_inequality_operator(self):
47
addr1 = DBusAddress(fake_bus, "conn", "path")
49
self.assertThat(addr1, Not(NotEquals(DBusAddress(fake_bus, "conn", "path"))))
50
self.assertThat(addr1, NotEquals(DBusAddress(fake_bus, "conn", "new_path")))
51
self.assertThat(addr1, NotEquals(DBusAddress(fake_bus, "conn2", "path")))
52
self.assertThat(addr1, NotEquals(DBusAddress(object(), "conn", "path")))