~veebers/autopilot/move-testing-process-run-fixture

« back to all changes in this revision

Viewing changes to autopilot/tests/unit/test_exceptions.py

  • Committer: CI bot
  • Author(s): Tarmac
  • Date: 2014-06-13 00:30:58 UTC
  • mfrom: (483.2.40 temp-dev)
  • Revision ID: ps-jenkins@lists.canonical.com-20140613003058-upskx1j45sr08izi
Fix DateTime tests that failed due to recent DateTime changes that removed assumption of UTC TZ. Fixes: https://bugs.launchpad.net/bugs/1324441.
Set process on proxy object when launched via fixture (LP:1327377). Fixes: https://bugs.launchpad.net/bugs/1327377.
Add link to url troubleshooting guide when state not found error is raise.
Update docs version number in sphinx config.
Update Apparmor rules. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
#
19
19
 
20
 
import six
21
20
from testtools import TestCase
22
 
from testtools.matchers import raises, Equals
 
21
from testtools.matchers import raises, EndsWith, Equals
23
22
 
24
23
from autopilot.exceptions import StateNotFoundError
25
24
 
41
40
        err = StateNotFoundError("MyClass")
42
41
        self.assertThat(
43
42
            str(err),
44
 
            Equals("Object not found with name 'MyClass'.")
 
43
            Equals("Object not found with name 'MyClass'.\n\n{}".format(
 
44
                StateNotFoundError._troubleshoot_url_message
 
45
            ))
45
46
        )
46
 
        if not six.PY3:
47
 
            self.assertThat(
48
 
                unicode(err),
49
 
                Equals(u"Object not found with name 'MyClass'.")
50
 
            )
51
47
 
52
48
    def test_can_be_constructed_with_filters_only(self):
53
49
        """Must be able to construct exception with filters only."""
54
50
        err = StateNotFoundError(foo="bar")
55
51
        self.assertThat(
56
52
            str(err),
57
 
            Equals("Object not found with properties {'foo': 'bar'}.")
 
53
            Equals(
 
54
                "Object not found with properties {}."
 
55
                "\n\n{}".format(
 
56
                    "{'foo': 'bar'}",
 
57
                    StateNotFoundError._troubleshoot_url_message
 
58
                ))
58
59
        )
59
 
        if not six.PY3:
60
 
            self.assertThat(
61
 
                unicode(err),
62
 
                Equals(u"Object not found with properties {'foo': 'bar'}.")
63
 
            )
64
60
 
65
61
    def test_can_be_constructed_with_class_name_and_filters(self):
66
62
        """Must be able to construct with both class name and filters."""
68
64
        self.assertThat(
69
65
            str(err),
70
66
            Equals("Object not found with name 'MyClass'"
71
 
                   " and properties {'foo': 'bar'}.")
 
67
                   " and properties {}.\n\n{}".format(
 
68
                       "{'foo': 'bar'}",
 
69
                       StateNotFoundError._troubleshoot_url_message
 
70
                   ))
72
71
        )
73
 
        if not six.PY3:
74
 
            self.assertThat(
75
 
                unicode(err),
76
 
                Equals(u"Object not found with name 'MyClass'"
77
 
                       " and properties {'foo': 'bar'}.")
 
72
 
 
73
    def test_StateNotFoundError_endswith_troubleshoot_url_message_text(self):
 
74
        """The assertion raised must end with a link to troubleshooting url."""
 
75
        err = StateNotFoundError('MyClass', foo="bar")
 
76
        self.assertThat(
 
77
            str(err),
 
78
            EndsWith(
 
79
                'Tips on minimizing the occurrence of this failure'
 
80
                'are available here: '
 
81
                'http://developer.ubuntu.com/api/devel/ubuntu-14.10/python/'
 
82
                'autopilot/faq/troubleshooting.html'
78
83
            )
 
84
        )