Fixing and refactoring of clean/info resource methods
This commit is contained in:
parent
825ae24a72
commit
c5a5fc7854
4 changed files with 119 additions and 99 deletions
|
|
@ -102,7 +102,6 @@ class ClientTestCase(TestCase):
|
|||
buff = StringIO(u'test content for testing of webdav client')
|
||||
self.client.upload_to(buff=buff, remote_path=self.remote_path_file)
|
||||
self.assertTrue(self.client.check(self.remote_path_file), 'Expected the file is uploaded.')
|
||||
self.test_download_to()
|
||||
|
||||
def test_upload(self):
|
||||
self._prepare_for_uploading()
|
||||
|
|
@ -146,6 +145,20 @@ class ClientTestCase(TestCase):
|
|||
self.assertFalse(self.client.check(remote_path=self.remote_path_file))
|
||||
self.assertTrue(self.client.check(remote_path=self.remote_path_file2))
|
||||
|
||||
def test_clean(self):
|
||||
self._prepare_for_downloading()
|
||||
self.client.clean(remote_path=self.remote_path_dir)
|
||||
self.assertFalse(self.client.check(remote_path=self.remote_path_file))
|
||||
self.assertFalse(self.client.check(remote_path=self.remote_path_dir))
|
||||
|
||||
def test_info(self):
|
||||
self._prepare_for_downloading()
|
||||
result = self.client.info(remote_path=self.remote_path_file)
|
||||
self.assertEquals(result['name'], 'test.txt')
|
||||
self.assertEquals(result['size'], '41')
|
||||
self.assertTrue('created' in result)
|
||||
self.assertTrue('modified' in result)
|
||||
|
||||
def test_get_property(self):
|
||||
self._prepare_for_downloading()
|
||||
result = self.client.get_property(remote_path=self.remote_path_file, option={'name': 'aProperty'})
|
||||
|
|
@ -169,8 +182,6 @@ class ClientTestCase(TestCase):
|
|||
self.client.upload_file(remote_path=self.remote_path_file, local_path=self.local_path_file)
|
||||
|
||||
def _prepare_for_uploading(self):
|
||||
if self.client.check(remote_path=self.remote_path_file):
|
||||
self.client.clean(remote_path=self.remote_path_file)
|
||||
if not self.client.check(remote_path=self.remote_path_dir):
|
||||
self.client.mkdir(remote_path=self.remote_path_dir)
|
||||
if not path.exists(path=self.local_path_dir):
|
||||
|
|
|
|||
|
|
@ -32,6 +32,20 @@ class ClientTestCase(TestCase):
|
|||
result = utils.parse_free_space_response(content, 'localhost')
|
||||
self.assertEquals(result, 10737417543)
|
||||
|
||||
def test_parse_info_response(self):
|
||||
content = '<?xml version="1.0" encoding="utf-8"?><d:multistatus xmlns:d="DAV:"><d:response>' \
|
||||
'<d:href>/test_dir/test.txt</d:href><d:propstat><d:status>HTTP/1.1 200 OK</d:status><d:prop>' \
|
||||
'<d:resourcetype/><d:getlastmodified>Wed, 18 Oct 2017 15:16:04 GMT</d:getlastmodified>' \
|
||||
'<d:getetag>ab0b4b7973803c03639b848682b5f38c</d:getetag><d:getcontenttype>text/plain' \
|
||||
'</d:getcontenttype><d:getcontentlength>41</d:getcontentlength><d:displayname>test.txt' \
|
||||
'</d:displayname><d:creationdate>2017-10-18T15:16:04Z</d:creationdate></d:prop></d:propstat>' \
|
||||
'</d:response></d:multistatus>'
|
||||
result = utils.parse_info_response(content, '/test_dir/test.txt', 'localhost')
|
||||
self.assertEquals(result['created'], '2017-10-18T15:16:04Z')
|
||||
self.assertEquals(result['name'], 'test.txt')
|
||||
self.assertEquals(result['modified'], 'Wed, 18 Oct 2017 15:16:04 GMT')
|
||||
self.assertEquals(result['size'], '41')
|
||||
|
||||
def test_create_get_property_request_content(self):
|
||||
option = {
|
||||
'namespace': 'test',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue