~ubuntu-branches/ubuntu/utopic/maas/utopic-updates

« back to all changes in this revision

Viewing changes to src/maasserver/models/tests/test_bootsource.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez, Jeroen Vermeulen, Andres Rodriguez, Jason Hobbs, Raphaël Badin, Louis Bouchard, Gavin Panella
  • Date: 2014-08-21 19:36:30 UTC
  • mfrom: (1.3.1)
  • Revision ID: package-import@ubuntu.com-20140821193630-kertpu5hd8yyss8h
Tags: 1.7.0~beta7+bzr3266-0ubuntu1
* New Upstream Snapshot, Beta 7 bzr3266

[ Jeroen Vermeulen ]
* debian/extras/99-maas-sudoers
  debian/maas-dhcp.postinst
  debian/rules
  - Add second DHCP server instance for IPv6.
* debian/maas-region-controller-min.install
  debian/maas-region-controller-min.lintian-overrides
  - Install deployment user-data: maas_configure_interfaces.py script.
* debian/maas-cluster-controller.links
  debian/maas-cluster-controller.install
  debian/maas-cluster-controller.postinst
  - Reflect Celery removal changes made in trunk r3067.
  - Don't install celeryconfig_cluster.py any longer. 
  - Don't install maas_local_celeryconfig_cluster.py any longer.
  - Don't symlink maas_local_celeryconfig_cluster.py from /etc to /usr.
  - Don't insert UUID into maas_local_celeryconfig_cluster.py.

[ Andres Rodriguez ]
* debian/maas-region-controller-min.postrm: Cleanup lefover files.
* debian/maas-dhcp.postrm: Clean leftover configs.
* Provide new maas-proxy package that replaces the usage of
  squid-deb-proxy:
  - debian/control: New maas-proxy package that replaces the usage
    of squid-deb-proxy; Drop depends on squid-deb-proxy.
  - Add upstrart job.
  - Ensure squid3 is stopped as maas-proxy uses a caching proxy.
* Remove Celery references to cluster controller:
  - Rename upstart job from maas-pserv to maas-cluster; rename
    maas-cluster-celery to maas-cluster-register. Ensure services
    are stopped on upgrade.
  - debian/maintscript: Cleanup config files.
  - Remove all references to the MAAS celery daemon and config
    files as we don't use it like that anymore
* Move some entries in debian/maintscript to
  debian/maas-cluster-controller.maintscript
* Remove usage of txlongpoll and rabbitmq-server. Handle upgrades
  to ensure these are removed correctly.

[ Jason Hobbs ]
* debian/maas-region-controller-min.install: Install
  maas-generate-winrm-cert script.

[ Raphaël Badin ]
* debian/extras/maas-region-admin: Bypass django-admin as it prints
  spurious messages to stdout (LP: #1365130).

[Louis Bouchard]
* debian/maas-cluster-controller.postinst:
  - Exclude /var/log/maas/rsyslog when changing ownership
    (LP: #1346703)

[Gavin Panella]
* debian/maas-cluster-controller.maas-clusterd.upstart:
  - Don't start-up the cluster controller unless a shared-secret has
    been installed.
* debian/maas-cluster-controller.maas-cluster-register.upstart: Drop.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
__metaclass__ = type
15
15
__all__ = []
16
16
 
17
 
from base64 import b64encode
18
17
import os
19
18
 
20
19
from django.core.exceptions import ValidationError
 
20
from maasserver.bootsources import _cache_boot_sources
21
21
from maasserver.models import BootSource
22
22
from maasserver.testing.factory import factory
23
23
from maasserver.testing.testcase import MAASServerTestCase
 
24
from maastesting.matchers import MockCalledOnceWith
 
25
from twisted.internet import reactor
 
26
from twisted.internet.threads import deferToThread
24
27
 
25
28
 
26
29
class TestBootSource(MAASServerTestCase):
35
38
            BootSource.objects.filter(id=boot_source.id).exists())
36
39
 
37
40
    def test_url_is_unqiue(self):
38
 
        boot_source = factory.make_boot_source()
 
41
        boot_source = factory.make_BootSource()
39
42
        self.assertRaises(
40
 
            ValidationError, factory.make_boot_source, url=boot_source.url)
 
43
            ValidationError, factory.make_BootSource, url=boot_source.url)
41
44
 
42
45
    def test_cannot_set_keyring_data_and_filename(self):
43
46
        # A BootSource cannot have both a keyring filename and keyring
55
58
        self.assertRaises(ValidationError, boot_source.clean)
56
59
 
57
60
    def test_to_dict_returns_dict(self):
58
 
        boot_source = factory.make_boot_source(
 
61
        boot_source = factory.make_BootSource(
59
62
            keyring_data=b"123445", keyring_filename='')
60
 
        boot_source_selection = factory.make_boot_source_selection(
 
63
        boot_source_selection = factory.make_BootSourceSelection(
61
64
            boot_source=boot_source)
62
65
        boot_source_dict = boot_source.to_dict()
63
66
        self.assertEqual(boot_source.url, boot_source_dict['url'])
70
73
        keyring_file = self.make_file(contents=keyring_data)
71
74
        self.addCleanup(os.remove, keyring_file)
72
75
 
73
 
        boot_source = factory.make_boot_source(
 
76
        boot_source = factory.make_BootSource(
74
77
            keyring_data=b"", keyring_filename=keyring_file)
75
78
        source = boot_source.to_dict()
76
79
        self.assertEqual(
77
80
            source['keyring_data'],
78
 
            b64encode(keyring_data))
 
81
            keyring_data)
79
82
 
80
83
    def test_to_dict_handles_keyring_data(self):
81
84
        keyring_data = b"Some Keyring Data"
82
 
        boot_source = factory.make_boot_source(
 
85
        boot_source = factory.make_BootSource(
83
86
            keyring_data=keyring_data, keyring_filename="")
84
87
        source = boot_source.to_dict()
85
88
        self.assertEqual(
86
89
            source['keyring_data'],
87
 
            b64encode(keyring_data))
 
90
            keyring_data)
 
91
 
 
92
    def test_to_dict_with_selections_returns_dict_without_selections(self):
 
93
        boot_source = factory.make_BootSource(
 
94
            keyring_data=b"123445", keyring_filename='')
 
95
        factory.make_BootSourceSelection(boot_source=boot_source)
 
96
        boot_source_dict = boot_source.to_dict_without_selections()
 
97
        self.assertEqual(
 
98
            [],
 
99
            boot_source_dict['selections'])
 
100
 
 
101
    def test_calls_cache_boot_sources_on_create(self):
 
102
        mock_callLater = self.patch(reactor, 'callLater')
 
103
        BootSource.objects.create(
 
104
            url="http://test.test/", keyring_data=b"1234")
 
105
        self.assertThat(
 
106
            mock_callLater,
 
107
            MockCalledOnceWith(1, deferToThread, _cache_boot_sources))