Example #1
0
    def test_boot_and_delete_server_with_keypair(self):
        scenario = keypairs.NovaKeypair(self.context)
        scenario.generate_random_name = mock.MagicMock(return_value="name")
        scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
        scenario._boot_server = mock.MagicMock(return_value="foo_server")
        scenario._delete_server = mock.MagicMock()
        scenario._delete_keypair = mock.MagicMock()

        fake_server_args = {
            "foo": 1,
            "bar": 2,
        }

        scenario.boot_and_delete_server_with_keypair(
            "img",
            1,
            server_kwargs=fake_server_args,
            fake_arg1="foo",
            fake_arg2="bar")

        scenario._create_keypair.assert_called_once_with(fake_arg1="foo",
                                                         fake_arg2="bar")

        scenario._boot_server.assert_called_once_with("img",
                                                      1,
                                                      foo=1,
                                                      bar=2,
                                                      key_name="foo_keypair")

        scenario._delete_server.assert_called_once_with("foo_server")

        scenario._delete_keypair.assert_called_once_with("foo_keypair")
Example #2
0
    def test_create_and_delete_keypair(self):
        scenario = keypairs.NovaKeypair(self.context)
        scenario.generate_random_name = mock.MagicMock(return_value="name")
        scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
        scenario._delete_keypair = mock.MagicMock()

        scenario.create_and_delete_keypair(fakearg="fakearg")

        scenario._create_keypair.assert_called_once_with(fakearg="fakearg")
        scenario._delete_keypair.assert_called_once_with("foo_keypair")
Example #3
0
    def test_create_and_list_keypairs(self):
        scenario = keypairs.NovaKeypair()
        scenario._generate_random_name = mock.MagicMock(return_value="name")
        scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
        scenario._list_keypairs = mock.MagicMock()

        scenario.create_and_list_keypairs(fakearg="fakearg")

        scenario._create_keypair.assert_called_once_with(fakearg="fakearg")
        scenario._list_keypairs.assert_called_once_with()
Example #4
0
    def test_boot_and_delete_server_with_keypair(self):
        scenario = keypairs.NovaKeypair(self.context)
        scenario._generate_random_name = mock.MagicMock(return_value="name")
        scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
        scenario._boot_server = mock.MagicMock(return_value="foo_server")
        scenario._delete_server = mock.MagicMock()
        scenario._delete_keypair = mock.MagicMock()

        scenario.boot_and_delete_server_with_keypair("img", 1)

        scenario._create_keypair.assert_called_once_with()

        scenario._boot_server.assert_called_once_with("img",
                                                      1,
                                                      key_name="foo_keypair")

        scenario._delete_server.assert_called_once_with("foo_server")

        scenario._delete_keypair.assert_called_once_with("foo_keypair")