def test_get_remote_object_works(self, mock_socket):
        client = ControlClient(host='127.0.0.1', port='10001')

        with patch.object(client, 'json_rpc') as json_rpc_mock:
            json_rpc_mock.return_value = ({'id': 2,
                                           'result': {'class': 'Test',
                                                      'methods': ['a:set', 'a:get', 'setTest']}},
                                          2)

            obj = client.get_object()

            self.assertTrue(hasattr(type(obj), 'a'))
            self.assertTrue(hasattr(obj, 'setTest'))

            json_rpc_mock.assert_has_calls([call(':api')])
    def test_get_remote_object_works(self, mock_socket):
        client = ControlClient(host='127.0.0.1', port='10001')

        with patch.object(client, 'json_rpc') as json_rpc_mock:
            json_rpc_mock.return_value = ({
                'id': 2,
                'result': {
                    'class': 'Test',
                    'methods': ['a:set', 'a:get', 'setTest']
                }
            }, 2)

            obj = client.get_object()

            self.assertTrue(hasattr(type(obj), 'a'))
            self.assertTrue(hasattr(obj, 'setTest'))

            json_rpc_mock.assert_has_calls([call(':api')])
Esempio n. 3
0
    def test_get_remote_object_works(self, mock_socket):
        client = ControlClient(host="127.0.0.1", port="10001")

        with patch.object(client, "json_rpc") as json_rpc_mock:
            json_rpc_mock.return_value = (
                {
                    "id": 2,
                    "result": {
                        "class": "Test",
                        "methods": ["a:set", "a:get", "setTest"],
                    },
                },
                2,
            )

            obj = client.get_object()

            self.assertTrue(hasattr(type(obj), "a"))
            self.assertTrue(hasattr(obj, "setTest"))

            json_rpc_mock.assert_has_calls([call(":api")])