def test_container_publish(self, ms): ms.return_value = ('200', fake_api.fake_operation()) self.assertEqual( ms.return_value, self.lxd.container_publish('trusty-1')) ms.assert_called_once_with('POST', '/1.0/images', '"trusty-1"')
def test_operation_info(self, ms): ms.return_value = ('200', fake_api.fake_operation()) self.assertEqual(ms.return_value, self.lxd.operation_info('/1.0/operations/1234')) ms.assert_called_with('GET', '/1.0/operations/1234')
import datetime from ddt import ddt import mock from pylxd.deprecated import connection from pylxd.deprecated.tests import annotated_data from pylxd.deprecated.tests import fake_api from pylxd.deprecated.tests import LXDAPITestBase @ddt @mock.patch.object(connection.LXDConnection, 'get_object', return_value=(200, fake_api.fake_operation())) class LXDAPIOperationTestObject(LXDAPITestBase): def test_list_operations(self, ms): ms.return_value = ('200', fake_api.fake_operation_list()) self.assertEqual(['/1.0/operations/1234'], self.lxd.list_operations()) ms.assert_called_with('GET', '/1.0/operations') def test_operation_info(self, ms): ms.return_value = ('200', fake_api.fake_operation()) self.assertEqual(ms.return_value, self.lxd.operation_info('/1.0/operations/1234')) ms.assert_called_with('GET', '/1.0/operations/1234') @annotated_data( ('create_time', datetime.datetime.utcfromtimestamp( 1433876844).strftime('%Y-%m-%d %H:%M:%S')),
def test_container_publish(self, ms): ms.return_value = ("200", fake_api.fake_operation()) self.assertEqual(ms.return_value, self.lxd.container_publish("trusty-1")) ms.assert_called_once_with("POST", "/1.0/images", '"trusty-1"')
import json import tempfile from collections import OrderedDict import mock from ddt import ddt from pylxd.deprecated import connection from pylxd.deprecated.tests import LXDAPITestBase, annotated_data, fake_api @ddt @mock.patch.object( connection.LXDConnection, "get_object", return_value=("200", fake_api.fake_operation()), ) class LXDAPIContainerTestObject(LXDAPITestBase): def test_list_containers(self, ms): ms.return_value = ("200", fake_api.fake_container_list()) self.assertEqual(["trusty-1"], self.lxd.container_list()) ms.assert_called_once_with("GET", "/1.0/containers") @annotated_data( ("STOPPED", False), ("STOPPING", False), ("ABORTING", False), ("RUNNING", True), ("STARTING", True), ("FREEZING", True), ("FROZEN", True),
def test_operation_info(self, ms): ms.return_value = ('200', fake_api.fake_operation()) self.assertEqual( ms.return_value, self.lxd.operation_info('/1.0/operations/1234')) ms.assert_called_with('GET', '/1.0/operations/1234')
# under the License. import datetime from ddt import ddt import mock from pylxd.deprecated import connection from pylxd.deprecated.tests import annotated_data from pylxd.deprecated.tests import fake_api from pylxd.deprecated.tests import LXDAPITestBase @ddt @mock.patch.object(connection.LXDConnection, 'get_object', return_value=(200, fake_api.fake_operation())) class LXDAPIOperationTestObject(LXDAPITestBase): def test_list_operations(self, ms): ms.return_value = ('200', fake_api.fake_operation_list()) self.assertEqual( ['/1.0/operations/1234'], self.lxd.list_operations()) ms.assert_called_with('GET', '/1.0/operations') def test_operation_info(self, ms): ms.return_value = ('200', fake_api.fake_operation()) self.assertEqual( ms.return_value, self.lxd.operation_info('/1.0/operations/1234')) ms.assert_called_with('GET',
from collections import OrderedDict from ddt import ddt import json import mock import tempfile from pylxd.deprecated import connection from pylxd.deprecated.tests import annotated_data from pylxd.deprecated.tests import fake_api from pylxd.deprecated.tests import LXDAPITestBase @ddt @mock.patch.object(connection.LXDConnection, 'get_object', return_value=('200', fake_api.fake_operation())) class LXDAPIContainerTestObject(LXDAPITestBase): def test_list_containers(self, ms): ms.return_value = ('200', fake_api.fake_container_list()) self.assertEqual( ['trusty-1'], self.lxd.container_list()) ms.assert_called_once_with('GET', '/1.0/containers') @annotated_data( ('STOPPED', False), ('STOPPING', False), ('ABORTING', False), ('RUNNING', True),
from ddt import ddt import json import mock import tempfile from pylxd.deprecated import connection from pylxd.deprecated.tests import annotated_data from pylxd.deprecated.tests import fake_api from pylxd.deprecated.tests import LXDAPITestBase @ddt @mock.patch.object(connection.LXDConnection, 'get_object', return_value=('200', fake_api.fake_operation())) class LXDAPIContainerTestObject(LXDAPITestBase): def test_list_containers(self, ms): ms.return_value = ('200', fake_api.fake_container_list()) self.assertEqual(['trusty-1'], self.lxd.container_list()) ms.assert_called_once_with('GET', '/1.0/containers') @annotated_data( ('STOPPED', False), ('STOPPING', False), ('ABORTING', False), ('RUNNING', True), ('STARTING', True), ('FREEZING', True), ('FROZEN', True), ('THAWED', True),
def test_operation_info(self, ms): ms.return_value = ("200", fake_api.fake_operation()) self.assertEqual(ms.return_value, self.lxd.operation_info("/1.0/operations/1234")) ms.assert_called_with("GET", "/1.0/operations/1234")