1
# Copyright 2012 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Tests for `maasserver.testing.yui3`."""
6
from __future__ import (
15
from maastesting.testcase import TestCase
16
from maastesting.yui3 import (
18
gen_failed_test_messages,
19
get_failed_tests_message,
21
from nose.tools import nottest
23
# Nose is over-zealous.
24
nottest(extract_tests)
25
nottest(gen_failed_test_messages)
26
nottest(get_failed_tests_message)
29
# From http://yuilibrary.com/yui/docs/test/#testsuite-level-events
33
'name': 'Test Suite 0',
41
'message': 'Test passed.',
47
'message': 'Assertion failed.',
61
'message': 'Test passed.',
67
'message': 'Assertion failed.',
86
'message': 'Test passed.',
92
'message': 'Assertion failed.',
100
'type': 'testsuite'},
106
class TestFunctions(TestCase):
108
def test_extract_tests_names(self):
114
"testSuite0.testCase2.test0",
115
"testSuite0.testCase2.test1",
117
observed_tests = extract_tests(example_results)
118
observed_test_names = set(observed_tests)
119
self.assertSetEqual(expected_names, observed_test_names)
121
def test_extract_tests(self):
123
"testCase0.test0": "pass",
124
"testCase0.test1": "fail",
125
"testCase1.test0": "pass",
126
"testCase1.test1": "fail",
127
"testSuite0.testCase2.test0": "pass",
128
"testSuite0.testCase2.test1": "fail",
132
for name, test in extract_tests(example_results).items()
134
self.assertDictEqual(expected_results, observed_results)
136
def test_gen_failed_test_messages(self):
137
expected_messages = {
138
"testCase0.test1: Assertion failed.",
139
"testCase1.test1: Assertion failed.",
140
"testSuite0.testCase2.test1: Assertion failed.",
142
observed_messages = gen_failed_test_messages(example_results)
143
self.assertSetEqual(expected_messages, set(observed_messages))
145
def test_get_failed_tests_message(self):
147
"testCase0.test1: Assertion failed."
149
"testCase1.test1: Assertion failed."
151
"testSuite0.testCase2.test1: Assertion failed."
153
observed_message = get_failed_tests_message(example_results)
154
self.assertEqual(expected_message, observed_message)