~launchpad-pqm/launchpad/devel

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
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

"""Test harness for running the buglinktarget.txt interface test

This module will run the interface test against the CVE, Specification and
Question implementations of that interface.
"""

__metaclass__ = type

__all__ = []

import unittest

from zope.component import getUtility

from canonical.launchpad.testing.systemdocs import (
    LayeredDocFileSuite,
    setUp,
    tearDown,
    )
from canonical.testing.layers import LaunchpadFunctionalLayer
from lp.answers.interfaces.questioncollection import IQuestionSet
from lp.blueprints.interfaces.specification import ISpecificationSet
from lp.bugs.interfaces.cve import ICveSet


def questionSetUp(test):
    setUp(test)
    test.globs['target'] = getUtility(IQuestionSet).get(1)


def cveSetUp(test):
    setUp(test)
    test.globs['target'] = getUtility(ICveSet)['2005-2730']


def specificationSetUp(test):
    setUp(test)
    test.globs['target'] = getUtility(ISpecificationSet).getByURL(
        'http://wiki.mozilla.org/Firefox:1.1_Product_Team')


def test_suite():
    suite = unittest.TestSuite()

    targets = [('cve', cveSetUp),
               ('question', questionSetUp),
               ('specification', specificationSetUp),
               ]

    for name, setUpMethod in targets:
        test = LayeredDocFileSuite('buglinktarget.txt',
                    setUp=setUpMethod, tearDown=tearDown,
                    layer=LaunchpadFunctionalLayer)
        suite.addTest(test)
    return suite


if __name__ == '__main__':
    unittest.main()