/usr/lib/python2.7/dist-packages/metadataserver/commissioning/tests/test_user_data.py is in python-django-maas 1.5+bzr2252-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # Copyright 2012-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test generation of commissioning user data."""
from __future__ import (
absolute_import,
print_function,
unicode_literals,
)
str = None
__metaclass__ = type
__all__ = []
from maasserver.testing.factory import factory
from maasserver.testing.testcase import MAASServerTestCase
from maastesting.matchers import MockCalledWith
from metadataserver.commissioning import user_data
from metadataserver.commissioning.user_data import generate_user_data
from mock import (
Mock,
sentinel,
)
from testtools.matchers import ContainsAll
class TestUserData(MAASServerTestCase):
def test_generate_user_data_produces_commissioning_script(self):
# generate_user_data produces a commissioning script which contains
# both definitions and use of various commands in python.
self.assertThat(
generate_user_data(), ContainsAll({
'maas-get',
'maas-signal',
'maas-ipmi-autodetect',
'def authenticate_headers',
'def encode_multipart_data',
}))
def test_nodegroup_passed_to_get_preseed_context(self):
# I don't care about what effect it has, I just want to know
# that it was passed as it can affect the contents of
# `server_host` in the context.
fake_context = dict(http_proxy=factory.getRandomString())
user_data.get_preseed_context = Mock(return_value=fake_context)
nodegroup = sentinel.nodegroup
generate_user_data(nodegroup)
self.assertThat(
user_data.get_preseed_context,
MockCalledWith(nodegroup=nodegroup))
def test_generate_user_data_generates_mime_multipart(self):
# The generate_user_data func should create a MIME multipart
# message consisting of cloud-config and x-shellscript
# attachments.
self.assertThat(
generate_user_data(), ContainsAll({
'multipart',
'Content-Type: text/cloud-config',
'Content-Type: text/x-shellscript',
}))
|