示例#1
0
 def mock_unsafe_io_with_server(host, test_data, server_io_function, server_expected_response, server_url, **payload):
     mocked_response = test_data['mocked_response']
     assert '{0}/ws/{1}/{2}/{3}/'.format(
         _create_server_api_url(),
         persisted_obj.workspace.name,
         test_data['api_end_point'],
         persisted_obj.id) == server_url
     return MockResponse(mocked_response, 200)
示例#2
0
 def mock_server_put(put_url,
                     update=False,
                     expected_response=201,
                     **params):
     assert put_url == '{0}/ws/test/{1}/{2}/?command_id={3}'.format(
         _create_server_api_url(), test_data['api_end_point'],
         test_data['id'], params['command_id'])
     assert expected_response == 200
     assert update == False
     return {'id': 1, 'ok': True, 'rev': ''}
示例#3
0
 def on_open(self):
     from faraday.client.persistence.server.server import _create_server_api_url, _post
     response = _post(_create_server_api_url() +
                      '/ws/{}/websocket_token/'.format(self.workspace_name),
                      expected_response=200)
     token = response['token']
     self.ws.send(
         json.dumps({
             'action': 'JOIN_WORKSPACE',
             'workspace': self.workspace_name,
             'token': token,
         }))
示例#4
0
 def mock_server_post(test_data, post_url, update=False, expected_response=201, **params):
     assert post_url == '{0}/ws/test/{1}/?command_id={2}'.format(_create_server_api_url(), test_data['api_end_point'], params['command_id'])
     assert expected_response == 201
     assert update == False
     metadata = params.pop('metadata')
     assert metadata['owner'] == test_data['expected_payload']['owner']
     params.pop('command_id')
     test_data['expected_payload'].pop('command_id')
     assert params == test_data['expected_payload']
     return {
         'id': 1,
         'ok': True,
         'rev': ''
     }
示例#5
0
        def mock_server_put(test_data, put_url, update=False, expected_response=201, **params):
            assert put_url == '{0}/ws/test/{1}/{2}/'.format(_create_server_api_url(), test_data['api_end_point'], test_data['id'])
            assert expected_response == 200
            assert update == False
            if obj_class not in [Command]:
                metadata = params.pop('metadata')
                assert metadata['owner'] == test_data['expected_payload']['owner']
            params.pop('command_id', None)
            test_data['expected_payload'].pop('command_id', None)
            assert params == test_data['expected_payload']

            return {
                'id': 1,
                'ok': True,
                'rev': ''
            }
示例#6
0
 def test_create_server_api_url(self):
     s = server._create_server_api_url()
     self.assertEqual("{0}/_api/v2".format(server.SERVER_URL), s)