~martin-nowack/ubuntu/utopic/maas/bug-1425837

« back to all changes in this revision

Viewing changes to src/maasserver/testing/orm.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez, Diogo Matsubara, Jeroen Vermeulen, Raphaël Badin, Greg Lutostanski, Gavin Panella, Julian Edwards, Graham Binns, Andres Rodriguez
  • Date: 2014-08-21 14:05:40 UTC
  • mfrom: (1.2.35)
  • Revision ID: package-import@ubuntu.com-20140821140540-khodrzopm91kl4le
Tags: 1.7.0~beta1+bzr2781-0ubuntu1
* New upstream release, 1.7.0 Beta 1

[Diogo Matsubara]
* debian/control:
  - maas-cluster-controller depends on syslinux-dev | 
    syslinux-common (LP: #1328659)
  - python-maas-provisioningserver depends on
    python-paramiko (LP: #1334401)

[Jeroen Vermeulen]
* debian/extras/99-maas-sudoers:
  - Let maas user import, including sudo tgt-admin and sudo uec2roottar.
* debian/maas-cluster-controller.install:
  - Stop installing obsolete file bootresources.yaml.

[ Raphaël Badin ]
* debian/control:
  - maas-cluster-controller depends on python-pexpect
* debian/extras/99-maas-sudoers:
  - Add rule 'maas-dhcp-server stop' job.

[ Greg Lutostanski ]
* debian/control:
  - maas-cluster-controller depends on grub-common
  - maas-provisioningserver not maas-cluster-controller depends on
    python-pexpect (LP: #1352273)
  - maas-provisioningserver not maas-cluster-controller depends on
    python-seamicroclient (LP: #1332532)

[ Gavin Panella ]
* debian/maas-cluster-controller.postinst
  - Allow maas-pserv to bind to all IPv6 addresses too.

[ Julian Edwards ]
* debian/maas-region-controller-min.apport
  debian/maas-region-controller-min.logrotate
  debian/maas-region-controller-min.postinst
  debian/maas-region-controller.postinst
  - Change the log file name maas.log to maas-django.log
* debian/maas-cluster-controller.postinst
  debian/maas-common.install
  debian/maas-region-controller-min.postinst
  debian/maas-region-controller.postinst
  - Install /var/log/maas/maas.log as a syslog file.
  - Ensure logging is set up for upgrades 

[ Graham Binns ]
* debian/maas-region-controller.postinst:
  - Add symlinks for squid3, squid-deb-proxy and apache log directories to
    /var/log/maas.

[ Andres Rodriguez ]
* debian/maas-region-controller.postinst: Force symlink creation
  for external logs.
* debian/maas-region-controller.postinst: Do not change celery's
  rabbitmq password on upgrade that to not lock remote
  Cluster Controllers if upgrading from 1.5+. (LP: #1300507)

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
"""ORM-related test helpers."""
 
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
    'reload_object',
 
17
    'reload_objects',
 
18
    ]
 
19
 
 
20
from maasserver.utils.orm import get_one
 
21
 
 
22
 
 
23
def reload_object(model_object):
 
24
    """Reload `obj` from the database.
 
25
 
 
26
    Use this when a test needs to inspect changes to model objects made by
 
27
    the API.
 
28
 
 
29
    If the object has been deleted, this will return None.
 
30
 
 
31
    :param model_object: Model object to reload.
 
32
    :type model_object: Concrete `Model` subtype.
 
33
    :return: Freshly-loaded instance of `model_object`, or None.
 
34
    :rtype: Same as `model_object`.
 
35
    """
 
36
    model_class = model_object.__class__
 
37
    return get_one(model_class.objects.filter(id=model_object.id))
 
38
 
 
39
 
 
40
def reload_objects(model_class, model_objects):
 
41
    """Reload `model_objects` of type `model_class` from the database.
 
42
 
 
43
    Use this when a test needs to inspect changes to model objects made by
 
44
    the API.
 
45
 
 
46
    If any of the objects have been deleted, they will not be included in
 
47
    the result.
 
48
 
 
49
    :param model_class: `Model` class to reload from.
 
50
    :type model_class: Class.
 
51
    :param model_objects: Objects to reload from the database.
 
52
    :type model_objects: Sequence of `model_class` objects.
 
53
    :return: Reloaded objects, in no particular order.
 
54
    :rtype: Sequence of `model_class` objects.
 
55
    """
 
56
    assert all(isinstance(obj, model_class) for obj in model_objects)
 
57
    return model_class.objects.filter(
 
58
        id__in=[obj.id for obj in model_objects])