1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""
Run the view tests.
"""
import logging
import os
import unittest
from canonical.launchpad.testing.systemdocs import (
LayeredDocFileSuite,
setUp,
tearDown,
)
from canonical.testing.layers import (
DatabaseFunctionalLayer,
LaunchpadFunctionalLayer,
)
here = os.path.dirname(os.path.realpath(__file__))
# The default layer of view tests is the DatabaseFunctionalLayer. Tests
# that require something special like the librarian, memcaches, or mailman
# must run on a layer that sets those services up.
special_test_layer = {
'distribution-views.txt': LaunchpadFunctionalLayer,
'distributionsourcepackage-views.txt': LaunchpadFunctionalLayer,
'gpg-views.txt': LaunchpadFunctionalLayer,
'karmacontext-views.txt': LaunchpadFunctionalLayer,
'mailinglist-message-views.txt': LaunchpadFunctionalLayer,
'milestone-views.txt': LaunchpadFunctionalLayer,
'person-views.txt': LaunchpadFunctionalLayer,
'product-edit-people-view.txt': LaunchpadFunctionalLayer,
'product-files-views.txt': LaunchpadFunctionalLayer,
'product-views.txt': LaunchpadFunctionalLayer,
'productseries-views.txt': LaunchpadFunctionalLayer,
'projectgroup-views.txt': LaunchpadFunctionalLayer,
'user-to-user-views.txt': LaunchpadFunctionalLayer,
}
def test_suite():
suite = unittest.TestSuite()
testsdir = os.path.abspath(here)
# Add tests using default setup/teardown
filenames = [filename
for filename in os.listdir(testsdir)
if filename.endswith('.txt')]
# Sort the list to give a predictable order.
filenames.sort()
for filename in filenames:
path = filename
layer = special_test_layer.get(path, DatabaseFunctionalLayer)
one_test = LayeredDocFileSuite(
path, setUp=setUp, tearDown=tearDown, layer=layer,
stdout_logging_level=logging.WARNING)
suite.addTest(one_test)
return suite
|