~ubuntu-branches/ubuntu/quantal/maas/quantal-updates

« back to all changes in this revision

Viewing changes to src/maastesting/tests/test_testcase.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 `TestCase`."""
 
5
 
 
6
from __future__ import (
 
7
    absolute_import,
 
8
    print_function,
 
9
    unicode_literals,
 
10
    )
 
11
 
 
12
__metaclass__ = type
 
13
__all__ = []
 
14
 
 
15
import os.path
 
16
from shutil import rmtree
 
17
from tempfile import mkdtemp
 
18
 
 
19
from maastesting.testcase import TestCase
 
20
from testtools.matchers import (
 
21
    DirExists,
 
22
    FileExists,
 
23
    )
 
24
 
 
25
 
 
26
class TestTestCase(TestCase):
 
27
    """Tests the base `TestCase` facilities."""
 
28
 
 
29
    def test_make_dir_creates_directory(self):
 
30
        self.assertThat(self.make_dir(), DirExists())
 
31
 
 
32
    def test_make_dir_creates_temporary_directory(self):
 
33
        other_temp_dir = mkdtemp()
 
34
        self.addCleanup(rmtree, other_temp_dir)
 
35
        other_temp_root, other_subdir = os.path.split(other_temp_dir)
 
36
        temp_root, subdir = os.path.split(self.make_dir())
 
37
        self.assertEqual(other_temp_root, temp_root)
 
38
        self.assertNotIn(subdir, [b'', u'', None])
 
39
 
 
40
    def test_make_dir_creates_one_directory_per_call(self):
 
41
        self.assertNotEqual(self.make_dir(), self.make_dir())
 
42
 
 
43
    def test_make_file_creates_file(self):
 
44
        self.assertThat(self.make_file(), FileExists())
 
45
 
 
46
    def test_make_file_uses_temporary_directory(self):
 
47
        directory = self.make_dir()
 
48
        self.patch(self, 'make_dir', lambda: directory)
 
49
        dir_part, file_part = os.path.split(self.make_file())
 
50
        self.assertEqual(directory, dir_part)