~ubuntu-branches/ubuntu/utopic/maas/utopic-security

« back to all changes in this revision

Viewing changes to src/maasserver/tests/test_forms_instancelistfield.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:
 
1
# Copyright 2014 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
"""Tests for `InstanceListField`."""
 
5
 
 
6
from __future__ import (
 
7
    absolute_import,
 
8
    print_function,
 
9
    unicode_literals,
 
10
    )
 
11
 
 
12
str = None
 
13
 
 
14
__metaclass__ = type
 
15
__all__ = []
 
16
 
 
17
from django.core.exceptions import ValidationError
 
18
from maasserver.forms import InstanceListField
 
19
from maasserver.models import Node
 
20
from maasserver.testing.factory import factory
 
21
from maasserver.testing.testcase import MAASServerTestCase
 
22
 
 
23
 
 
24
class TestInstanceListField(MAASServerTestCase):
 
25
    """Tests for `InstanceListField`."""
 
26
 
 
27
    def test_field_validates_valid_data(self):
 
28
        nodes = [factory.make_Node() for _ in range(3)]
 
29
        # Create other nodes.
 
30
        [factory.make_Node() for _ in range(3)]
 
31
        field = InstanceListField(model_class=Node, field_name='system_id')
 
32
        input_data = [node.system_id for node in nodes]
 
33
        self.assertItemsEqual(
 
34
            input_data,
 
35
            [node.system_id for node in field.clean(input_data)])
 
36
 
 
37
    def test_field_ignores_duplicates(self):
 
38
        nodes = [factory.make_Node() for _ in range(2)]
 
39
        # Create other nodes.
 
40
        [factory.make_Node() for _ in range(3)]
 
41
        field = InstanceListField(model_class=Node, field_name='system_id')
 
42
        input_data = [node.system_id for node in nodes] * 2
 
43
        self.assertItemsEqual(
 
44
            set(input_data),
 
45
            [node.system_id for node in field.clean(input_data)])
 
46
 
 
47
    def test_field_rejects_invalid_data(self):
 
48
        nodes = [factory.make_Node() for _ in range(3)]
 
49
        field = InstanceListField(model_class=Node, field_name='system_id')
 
50
        error = self.assertRaises(
 
51
            ValidationError,
 
52
            field.clean, [node.system_id for node in nodes] + ['unknown'])
 
53
        self.assertEquals(['Unknown node(s): unknown.'], error.messages)