~lutostag/ubuntu/trusty/maas/1.5.2+packagefix

« back to all changes in this revision

Viewing changes to src/maasserver/support/pertenant/tests/test_migration.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-03-28 10:43:53 UTC
  • mto: This revision was merged to the branch mainline in revision 57.
  • Revision ID: package-import@ubuntu.com-20140328104353-ekpolg0pm5xnvq2s
Tags: upstream-1.5+bzr2204
ImportĀ upstreamĀ versionĀ 1.5+bzr2204

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2012, 2013 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2012-2014 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Test `maasserver.support.pertenant.migration."""
45
45
    )
46
46
from maasserver.testing.factory import factory
47
47
from maasserver.testing.testcase import MAASServerTestCase
 
48
from maastesting.matchers import MockCalledOnceWith
48
49
from mock import (
49
50
    call,
50
51
    sentinel,
233
234
        file = factory.make_file_storage(owner=None)
234
235
        save = self.patch(file, "save")
235
236
        give_file_to_user(file, user)
236
 
        save.assert_called_once()
 
237
        self.assertThat(save, MockCalledOnceWith())
237
238
 
238
239
 
239
240
class TestGiveCredentialsToUser(MAASServerTestCase):
291
292
        migrate_to_user(sentinel.user)
292
293
 
293
294
        # Each unowned file is given to the destination user one at a time.
294
 
        get_unowned_files.assert_called_once()
 
295
        self.assertThat(get_unowned_files, MockCalledOnceWith())
295
296
        self.assertEqual(
296
297
            [call(sentinel.file1, sentinel.user),
297
298
             call(sentinel.file2, sentinel.user)],
299
300
        # The SSH keys of each node owner are copied to the destination user,
300
301
        # one at a time, and the credentials of these users are given to the
301
302
        # destination user.
302
 
        get_owned_nodes_owners.assert_called_once()
 
303
        self.assertThat(get_owned_nodes_owners, MockCalledOnceWith())
303
304
        self.assertEqual(
304
305
            [call(sentinel.node_owner1, sentinel.user),
305
306
             call(sentinel.node_owner2, sentinel.user)],
309
310
             call(sentinel.node_owner2, sentinel.user)],
310
311
            give_api_credentials_to_user.call_args_list)
311
312
        # Each owned node is given to the destination user one at a time.
312
 
        get_owned_nodes.assert_called_once()
 
313
        self.assertThat(get_owned_nodes, MockCalledOnceWith())
313
314
        self.assertEqual(
314
315
            [call(sentinel.node1, sentinel.user),
315
316
             call(sentinel.node2, sentinel.user)],