~ubuntu-branches/ubuntu/quantal/maas/quantal-proposed

« back to all changes in this revision

Viewing changes to src/maastesting/tests/test_scenarios.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2012 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
"""Tests for `maastesting.scenarios`."""
 
5
 
 
6
from __future__ import (
 
7
    absolute_import,
 
8
    print_function,
 
9
    unicode_literals,
 
10
    )
 
11
 
 
12
__metaclass__ = type
 
13
__all__ = []
 
14
 
 
15
import unittest
 
16
 
 
17
from maastesting.scenarios import WithScenarios
 
18
from maastesting.testcase import TestCase
 
19
 
 
20
 
 
21
class TestWithScenarios(TestCase):
 
22
 
 
23
    def test_scenarios_applied(self):
 
24
        # Scenarios are applied correctly when a test is called via __call__()
 
25
        # instead of run().
 
26
 
 
27
        events = []
 
28
 
 
29
        class Test(WithScenarios, unittest.TestCase):
 
30
 
 
31
            scenarios = [
 
32
                ("one", dict(token="one")),
 
33
                ("two", dict(token="two")),
 
34
                ]
 
35
 
 
36
            def test(self):
 
37
                events.append(self.token)
 
38
 
 
39
        test = Test("test")
 
40
        test.__call__()
 
41
 
 
42
        self.assertEqual(["one", "two"], events)
 
43
 
 
44
    def test_scenarios_applied_by_call(self):
 
45
        # Scenarios are applied by __call__() when it is called first, and not
 
46
        # by run().
 
47
 
 
48
        events = []
 
49
 
 
50
        class Test(WithScenarios, unittest.TestCase):
 
51
 
 
52
            scenarios = [
 
53
                ("one", dict(token="one")),
 
54
                ("two", dict(token="two")),
 
55
                ]
 
56
 
 
57
            def test(self):
 
58
                events.append(self.token)
 
59
 
 
60
            def run(self, result=None):
 
61
                # Call-up right past WithScenarios.run() to show that it is
 
62
                # not responsible for applying scenarios, and __call__() is.
 
63
                super(WithScenarios, self).run(result)
 
64
 
 
65
        test = Test("test")
 
66
        test.__call__()
 
67
 
 
68
        self.assertEqual(["one", "two"], events)