コード例 #1
0
class ConnectionTemplatesTest(unittest.TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._connection_templates = ConnectionTemplates(self.connection)

    @mock.patch.object(ResourceClient, 'get')
    def test_get_called_once(self, mock_get):
        self._connection_templates.get('7a9f7d09-3c24-4efe-928f-50a1af411120')

        mock_get.assert_called_once_with(
            '7a9f7d09-3c24-4efe-928f-50a1af411120')

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_all_called_once(self, mock_get_all):
        filter = 'name=TestName'
        sort = 'name:ascending'

        self._connection_templates.get_all(2, 500, filter, sort)

        mock_get_all.assert_called_once_with(2, 500, filter=filter, sort=sort)

    @mock.patch.object(ResourceClient, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self._connection_templates.get_by('name',
                                          'name1128673347-1465916352647')

        mock_get_by.assert_called_once_with('name',
                                            'name1128673347-1465916352647')

    @mock.patch.object(ResourceClient, 'get')
    def test_get_default_called_once(self, mock_get):
        self._connection_templates.get_default()
        uri = '/rest/connection-templates/defaultConnectionTemplate'

        mock_get.assert_called_once_with(uri)

    @mock.patch.object(ResourceClient, 'update')
    def test_update_called_once(self, mock_update):
        con_template = {
            "type": "connection-templates",
            "bandwidth": {
                "maximumBandwidth": 10000,
                "typicalBandwidth": 2000
            },
            "name": "CT-23"
        }
        self._connection_templates.update(con_template, 70)
        mock_update.assert_called_once_with(
            con_template,
            timeout=70,
            default_values=self._connection_templates.DEFAULT_VALUES)
コード例 #2
0
class ConnectionTemplatesTest(unittest.TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._connection_templates = ConnectionTemplates(self.connection)

    @mock.patch.object(ResourceHelper, 'do_requests_to_getall')
    def test_get_all_called_once(self, mock_get_all):
        filter = 'name=TestName'
        sort = 'name:ascending'

        self._connection_templates.get_all(2, 500, filter=filter, sort=sort)

        mock_get_all.assert_called_once_with(
            '/rest/connection-templates?start=2&count=500&filter=name%3DTestName&sort=name%3Aascending',
            500)

    @mock.patch.object(Resource, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self._connection_templates.get_by('name',
                                          'name1128673347-1465916352647')

        mock_get_by.assert_called_once_with('name',
                                            'name1128673347-1465916352647')

    @mock.patch.object(ResourceHelper, 'do_get')
    def test_get_default_called_once(self, mock_do_get):
        self._connection_templates.get_default()
        uri = '/rest/connection-templates/defaultConnectionTemplate'

        mock_do_get.assert_called_once_with(uri)

    @mock.patch.object(Resource, 'update')
    def test_update_called_once(self, mock_update):
        con_template = {
            "type": "connection-templates",
            "bandwidth": {
                "maximumBandwidth": 10000,
                "typicalBandwidth": 2000
            },
            "name": "CT-23"
        }
        self._connection_templates.update(con_template, 70)
        mock_update.assert_called_once_with(con_template, 70)
コード例 #3
0
class ConnectionTemplatesTest(unittest.TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._connection_templates = ConnectionTemplates(self.connection)

    @mock.patch.object(ResourceHelper, 'do_requests_to_getall')
    def test_get_all_called_once(self, mock_get_all):
        filter = 'name=TestName'
        sort = 'name:ascending'

        self._connection_templates.get_all(2, 500, filter=filter, sort=sort)

        mock_get_all.assert_called_once_with('/rest/connection-templates?start=2&count=500&filter=name%3DTestName&sort=name%3Aascending', 500)

    @mock.patch.object(Resource, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self._connection_templates.get_by(
            'name', 'name1128673347-1465916352647')

        mock_get_by.assert_called_once_with(
            'name', 'name1128673347-1465916352647')

    @mock.patch.object(ResourceHelper, 'do_get')
    def test_get_default_called_once(self, mock_do_get):
        self._connection_templates.get_default()
        uri = '/rest/connection-templates/defaultConnectionTemplate'

        mock_do_get.assert_called_once_with(uri)

    @mock.patch.object(Resource, 'update')
    def test_update_called_once(self, mock_update):
        con_template = {
            "type": "connection-templates",
            "bandwidth": {
                "maximumBandwidth": 10000,
                "typicalBandwidth": 2000
            },
            "name": "CT-23"
        }
        self._connection_templates.update(con_template, 70)
        mock_update.assert_called_once_with(con_template, 70)