Пример #1
0
    def setUp(self):
        super(TestProxyPrivate, self).setUp()

        def method(self, expected_type, value):
            return value

        self.sot = mock.Mock()
        self.sot.method = method

        self.fake_proxy = proxy.Proxy("session")
Пример #2
0
    def setUp(self):
        super(TestProxyCreate, self).setUp()

        self.session = mock.Mock()

        self.fake_result = "fake_result"
        self.res = mock.Mock(spec=CreateableResource)
        self.res.create = mock.Mock(return_value=self.fake_result)

        self.sot = proxy.Proxy(self.session)
Пример #3
0
    def setUp(self):
        super(TestProxyList, self).setUp()

        self.session = mock.Mock()

        self.args = {"a": "A", "b": "B", "c": "C"}
        self.fake_response = [resource.Resource()]

        self.sot = proxy.Proxy(self.session)
        ListableResource.list = mock.Mock()
        ListableResource.list.return_value = self.fake_response
Пример #4
0
    def setUp(self):
        super(TestProxyDelete, self).setUp()

        self.session = mock.Mock()

        self.fake_id = 1
        self.res = mock.Mock(spec=DeleteableResource)
        self.res.id = self.fake_id
        self.res.delete = mock.Mock()

        self.sot = proxy.Proxy(self.session)
        DeleteableResource.new = mock.Mock(return_value=self.res)
Пример #5
0
    def setUp(self):
        super(TestProxyPrivate, self).setUp()

        def method(self, expected_type, value):
            return value

        self.sot = mock.Mock()
        self.sot.method = method

        self.session = mock.Mock()
        self.session._sdk_connection = self.cloud
        self.fake_proxy = proxy.Proxy(self.session)
        self.fake_proxy._connection = self.cloud
Пример #6
0
    def setUp(self):
        super(TestProxyBulkCreate, self).setUp()

        class Res(resource.Resource):
            pass

        self.session = mock.Mock()
        self.result = mock.sentinel
        self.data = mock.Mock()

        self.sot = proxy.Proxy(self.session)
        self.cls = Res
        self.cls.bulk_create = mock.Mock(return_value=self.result)
Пример #7
0
    def setUp(self):
        super(TestProxyHead, self).setUp()

        self.session = mock.Mock()

        self.fake_id = 1
        self.fake_name = "fake_name"
        self.fake_result = "fake_result"
        self.res = mock.Mock(spec=HeadableResource)
        self.res.id = self.fake_id
        self.res.head = mock.Mock(return_value=self.fake_result)

        self.sot = proxy.Proxy(self.session)
        HeadableResource.new = mock.Mock(return_value=self.res)
Пример #8
0
    def setUp(self):
        super(TestProxyGet, self).setUp()

        self.session = mock.Mock()

        self.fake_id = 1
        self.fake_name = "fake_name"
        self.fake_result = "fake_result"
        self.res = mock.Mock(spec=RetrieveableResource)
        self.res.id = self.fake_id
        self.res.fetch = mock.Mock(return_value=self.fake_result)

        self.sot = proxy.Proxy(self.session)
        RetrieveableResource.new = mock.Mock(return_value=self.res)
Пример #9
0
    def setUp(self):
        super(TestProxyUpdate, self).setUp()

        self.session = mock.Mock()

        self.fake_id = 1
        self.fake_result = "fake_result"

        self.res = mock.Mock(spec=UpdateableResource)
        self.res.commit = mock.Mock(return_value=self.fake_result)

        self.sot = proxy.Proxy(self.session)

        self.attrs = {"x": 1, "y": 2, "z": 3}

        UpdateableResource.new = mock.Mock(return_value=self.res)
Пример #10
0
    def setUp(self):
        super(TestProxyCleanup, self).setUp()

        self.session = mock.Mock()
        self.session._sdk_connection = self.cloud

        self.fake_id = 1
        self.fake_name = "fake_name"
        self.fake_result = "fake_result"
        self.res = mock.Mock(spec=resource.Resource)
        self.res.id = self.fake_id
        self.res.created_at = '2020-01-02T03:04:05'
        self.res.updated_at = '2020-01-03T03:04:05'
        self.res_no_updated = mock.Mock(spec=resource.Resource)
        self.res_no_updated.created_at = '2020-01-02T03:04:05'

        self.sot = proxy.Proxy(self.session)

        self.delete_mock = mock.Mock()
Пример #11
0
    def setUp(self):
        super(TestProxyWaits, self).setUp()

        self.session = mock.Mock()
        self.sot = proxy.Proxy(self.session)
Пример #12
0
    def test_extract_name(self):

        results = proxy.Proxy(mock.Mock())._extract_name(self.url)
        self.assertEqual(self.parts, results)