Пример #1
0
 def test_preparecopymove_illegal_depth(self):
     """Test CoreWebDAVClient._preparecopymove with illegal depth value."""
     source = "/foo bar/baz"
     dest = "/dest/in/ation"
     headers = {"X-Test": "Hello"}
     http = CoreWebDAVClient("127.0.0.1", 80)
     http.setbasicauth(b"me", b"secret")
     with pytest.raises(ValueError):
         http._preparecopymove(source, dest, "1", False, headers)
Пример #2
0
 def test_preparecopymove(self):
     """Test CoreWebDAVClient._preparecopymove."""
     source = "/foo%20bar/baz"
     dest = "/dest/in/ation"
     headers = {"X-Test": "Hello"}
     http = CoreWebDAVClient("127.0.0.1", 80)
     http.setbasicauth(b"me", b"secret")
     (source, headers) = http._preparecopymove(source, dest, 0, False,
                                               headers)
     assert source == "/foo%20bar/baz"
     exp_headers = {
         "Destination": "http://127.0.0.1:80/dest/in/ation",
         "Overwrite": "F",
         "Authorization": "Basic bWU6c2VjcmV0",
         "X-Test": "Hello",
     }
     assert headers == exp_headers
Пример #3
0
 def test_preparecopymove(self):
     """Test CoreWebDAVClient._preparecopymove."""
     source = "/foo bar/baz"
     dest = "/dest/in/ation"
     headers = {"X-Test": "Hello"}
     query = {"foo": "bär"}
     http = CoreWebDAVClient("127.0.0.1", 80)
     http.setbasicauth("me", "secret")
     (source, headers) = http._preparecopymove(source, dest, 0,
                                               False, headers)
     self.assertEqual(source, "/foo%20bar/baz")
     exp_headers = {
         "Destination": "http://127.0.0.1:80/dest/in/ation",
         "Overwrite": "F",
         "Authorization": "Basic bWU6c2VjcmV0",
         "X-Test": "=?utf-8?q?Hello?=",
     }
     self.assertEqual(headers, exp_headers)
Пример #4
0
 def test_preparecopymove_col(self):
     """Test CoreWebDAVClient._preparecopymove with collection as source."""
     source = "/foo bar/baz/"
     dest = "/dest/in/ation"
     headers = {"X-Test": "Hello", "X-Test-2": "Umlaut ä"}
     query = {"foo": "bär"}
     http = CoreWebDAVClient("127.0.0.1", 80)
     http.setbasicauth("me", "secret")
     (source, headers) = http._preparecopymove(source, dest, 0,
                                               True, headers)
     self.assertEqual(source, "/foo%20bar/baz/")
     exp_headers = {
         "Destination": "http://127.0.0.1:80/dest/in/ation",
         "Depth": "0",
         "Overwrite": "T",
         "Authorization": "Basic bWU6c2VjcmV0",
         "X-Test": "Hello",
         "X-Test-2": "=?utf-8?b?VW1sYXV0IMOk?=",
     }
     self.assertEqual(headers, exp_headers)