Added method for settings of WebDAV resource property values in batch.
Prepared for release 0.5
This commit is contained in:
parent
354cf64d22
commit
743f8b96bb
6 changed files with 99 additions and 21 deletions
|
|
@ -160,10 +160,18 @@ class ClientTestCase(TestCase):
|
|||
self.assertTrue('created' in result)
|
||||
self.assertTrue('modified' in result)
|
||||
|
||||
def test_get_property(self):
|
||||
def test_directory_is_dir(self):
|
||||
self._prepare_for_downloading()
|
||||
self.assertTrue(self.client.is_dir(self.remote_path_dir), 'Should return True for directory')
|
||||
|
||||
def test_file_is_not_dir(self):
|
||||
self._prepare_for_downloading()
|
||||
self.assertFalse(self.client.is_dir(self.remote_path_file), 'Should return False for file')
|
||||
|
||||
def test_get_property_of_non_exist(self):
|
||||
self._prepare_for_downloading()
|
||||
result = self.client.get_property(remote_path=self.remote_path_file, option={'name': 'aProperty'})
|
||||
self.assertEquals(result, None)
|
||||
self.assertEquals(result, None, 'For not found property should return value as None')
|
||||
|
||||
def test_set_property(self):
|
||||
self._prepare_for_downloading()
|
||||
|
|
@ -174,7 +182,28 @@ class ClientTestCase(TestCase):
|
|||
})
|
||||
result = self.client.get_property(remote_path=self.remote_path_file,
|
||||
option={'namespace': 'test', 'name': 'aProperty'})
|
||||
self.assertEquals(result, "aValue")
|
||||
self.assertEquals(result, 'aValue', 'Property value should be set')
|
||||
|
||||
def test_set_property_batch(self):
|
||||
self._prepare_for_downloading()
|
||||
self.client.set_property_batch(remote_path=self.remote_path_file, option=[
|
||||
{
|
||||
'namespace': 'test',
|
||||
'name': 'aProperty',
|
||||
'value': 'aValue'
|
||||
},
|
||||
{
|
||||
'namespace': 'test',
|
||||
'name': 'aProperty2',
|
||||
'value': 'aValue2'
|
||||
}
|
||||
])
|
||||
result = self.client.get_property(remote_path=self.remote_path_file,
|
||||
option={'namespace': 'test', 'name': 'aProperty'})
|
||||
self.assertEquals(result, 'aValue', 'First property value should be set')
|
||||
result = self.client.get_property(remote_path=self.remote_path_file,
|
||||
option={'namespace': 'test', 'name': 'aProperty2'})
|
||||
self.assertEquals(result, 'aValue2', 'Second property value should be set')
|
||||
|
||||
def _prepare_for_downloading(self):
|
||||
if not self.client.check(remote_path=self.remote_path_dir):
|
||||
|
|
|
|||
|
|
@ -72,24 +72,56 @@ class ClientTestCase(TestCase):
|
|||
result = utils.parse_get_property_response(content=content, name='aProperty')
|
||||
self.assertEquals(result, 'aValue')
|
||||
|
||||
def test_create_set_property_request_content(self):
|
||||
def test_create_set_one_property_request_content(self):
|
||||
option = {
|
||||
'namespace': 'test',
|
||||
'name': 'aProperty',
|
||||
'value': 'aValue'
|
||||
}
|
||||
result = utils.create_set_property_request_content(option=option)
|
||||
result = utils.create_set_property_batch_request_content(options=[option])
|
||||
self.assertEquals(result, '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<propertyupdate xmlns="DAV:"><set><prop>'
|
||||
'<aProperty xmlns="test">aValue</aProperty></prop></set></propertyupdate>')
|
||||
|
||||
def test_create_set_property_request_content_name_only(self):
|
||||
def test_create_set_one_property_request_content_name_only(self):
|
||||
option = {
|
||||
'name': 'aProperty'
|
||||
}
|
||||
result = utils.create_set_property_request_content(option=option)
|
||||
result = utils.create_set_property_batch_request_content(options=[option])
|
||||
self.assertEquals(result, '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<propertyupdate xmlns="DAV:"><set><prop>'
|
||||
'<aProperty xmlns=""></aProperty></prop></set></propertyupdate>')
|
||||
|
||||
def test_create_set_property_batch_request_content(self):
|
||||
options = [
|
||||
{
|
||||
'namespace': 'test',
|
||||
'name': 'aProperty',
|
||||
'value': 'aValue'
|
||||
},
|
||||
{
|
||||
'namespace': 'test2',
|
||||
'name': 'aProperty2',
|
||||
'value': 'aValue2'
|
||||
}
|
||||
]
|
||||
result = utils.create_set_property_batch_request_content(options=options)
|
||||
self.assertEquals(result, '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<propertyupdate xmlns="DAV:"><set><prop>'
|
||||
'<aProperty xmlns="test">aValue</aProperty><aProperty2 xmlns="test2">aValue2'
|
||||
'</aProperty2></prop></set></propertyupdate>')
|
||||
|
||||
def test_create_set_property_batch_request_content_name_only(self):
|
||||
options = [
|
||||
{
|
||||
'name': 'aProperty'
|
||||
},
|
||||
{
|
||||
'name': 'aProperty2'
|
||||
}
|
||||
]
|
||||
result = utils.create_set_property_batch_request_content(options=options)
|
||||
self.assertEquals(result, '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<propertyupdate xmlns="DAV:"><set><prop>'
|
||||
'<aProperty xmlns=""></aProperty><aProperty2 xmlns=""></aProperty2></prop></set>'
|
||||
'</propertyupdate>')
|
||||
|
||||
def test_etree_to_string(self):
|
||||
tree = ElementTree(Element('test'))
|
||||
result = utils.etree_to_string(tree)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue