~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to utilities/migrater/test_doc.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-25 08:55:37 UTC
  • mfrom: (13287.1.8 bug-800652)
  • Revision ID: launchpad@pqm.canonical.com-20110625085537-moikyoo2pe98zs7r
[r=jcsackett, julian-edwards][bug=800634,
        800652] Enable and display overrides on sync package uploads.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2012 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""
5
5
Run the doctests and pagetests.
6
6
"""
7
7
 
 
8
import logging
8
9
import os
 
10
import unittest
9
11
 
10
 
from lp.services.testing import build_test_suite
 
12
from canonical.database.sqlbase import flush_database_updates
 
13
from canonical.launchpad.testing.pages import PageTestSuite
 
14
from canonical.launchpad.testing.systemdocs import (
 
15
    LayeredDocFileSuite, setUp, tearDown)
 
16
from canonical.testing import (
 
17
    DatabaseFunctionalLayer, DatabaseLayer, LaunchpadFunctionalLayer,
 
18
    LaunchpadZopelessLayer)
 
19
from lp.registry.tests import mailinglists_helper
11
20
 
12
21
 
13
22
here = os.path.dirname(os.path.realpath(__file__))
14
23
 
 
24
 
15
25
special = {}
16
26
 
17
27
 
18
28
def test_suite():
19
 
    return build_test_suite(here, special)
 
29
    suite = unittest.TestSuite()
 
30
 
 
31
    stories_dir = os.path.join(os.path.pardir, 'stories')
 
32
    suite.addTest(PageTestSuite(stories_dir))
 
33
    stories_path = os.path.join(here, stories_dir)
 
34
    for story_dir in os.listdir(stories_path):
 
35
        full_story_dir = os.path.join(stories_path, story_dir)
 
36
        if not os.path.isdir(full_story_dir):
 
37
            continue
 
38
        story_path = os.path.join(stories_dir, story_dir)
 
39
        suite.addTest(PageTestSuite(story_path))
 
40
 
 
41
    testsdir = os.path.abspath(
 
42
        os.path.normpath(os.path.join(here, os.path.pardir, 'doc'))
 
43
        )
 
44
 
 
45
    # Add special needs tests
 
46
    for key in sorted(special):
 
47
        special_suite = special[key]
 
48
        suite.addTest(special_suite)
 
49
 
 
50
    # Add tests using default setup/teardown
 
51
    filenames = [filename
 
52
                 for filename in os.listdir(testsdir)
 
53
                 if filename.endswith('.txt') and filename not in special]
 
54
    # Sort the list to give a predictable order.
 
55
    filenames.sort()
 
56
    for filename in filenames:
 
57
        path = os.path.join('../doc/', filename)
 
58
        one_test = LayeredDocFileSuite(
 
59
            path, setUp=setUp, tearDown=tearDown,
 
60
            layer=LaunchpadFunctionalLayer,
 
61
            stdout_logging_level=logging.WARNING
 
62
            )
 
63
        suite.addTest(one_test)
 
64
 
 
65
    return suite