diff --git a/vos/vos/tests/test_vos.py b/vos/vos/tests/test_vos.py index 50850d65..b346f106 100644 --- a/vos/vos/tests/test_vos.py +++ b/vos/vos/tests/test_vos.py @@ -651,7 +651,7 @@ def test_create(self): node2 = Node(str(node)) self.assertEqual(node, node2) data = str(node) - headers = {'size': str(len(data))} + headers = {'size': str(len(data)), 'Content-Type': 'text/xml'} client = Client() # client.get_node_url = Mock(return_value='http://foo.com/bar') @@ -781,6 +781,23 @@ def test_delete(self): client.delete(uri1) mock_session.delete.assert_called_once_with(url) + @patch('vos.vos.net.ws.WsCapabilities.get_access_url', + Mock(return_value='http://www.canfar.phys.uvic.ca/vospace/nodes')) + def test_mkdir(self): + uri = 'vos://create.vospace.auth!vospace/bar' + client = Client() + node = Node(client.fix_uri(uri), Node.CONTAINER_NODE) + headers = {'Content-Type': 'text/xml'} + + client = Client() + session_mock = MagicMock() + client.get_session = Mock(return_value=session_mock) + + client.mkdir(uri) + session_mock.put.assert_called_with( + 'http://www.canfar.phys.uvic.ca/vospace/nodes/bar', + headers=headers, data=str(node)) + class TestNode(unittest.TestCase): """Test the vos Node class. diff --git a/vos/vos/vos.py b/vos/vos/vos.py index d5c6496a..a9a6c579 100644 --- a/vos/vos/vos.py +++ b/vos/vos/vos.py @@ -2541,7 +2541,7 @@ def create(self, uri): data = str(node) size = len(data) return Node(self.get_session(uri).put( - url, data=data, headers={'size': str(size)}).content) + url, data=data, headers={'size': str(size), 'Content-Type': 'text/xml'}).content) def update(self, node, recursive=False): """Updates the node properties on the server. For non-recursive @@ -2610,7 +2610,7 @@ def mkdir(self, uri): node = Node(uri, node_type="vos:ContainerNode") url = self.get_node_url(uri) try: - response = self.get_session(uri).put(url, data=str(node)) + response = self.get_session(uri).put(url, data=str(node), headers={'Content-Type': 'text/xml'}) response.raise_for_status() except HTTPError as http_error: if http_error.response.status_code != 409: