Example #1
0
 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"')
Example #2
0
 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"')
Example #3
0
 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')
Example #4
0
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')),
Example #5
0
 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"')
Example #6
0
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),
Example #7
0
 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')
Example #8
0
#    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',
Example #9
0
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),
Example #10
0
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),
Example #11
0
 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")