Exemplo n.º 1
0
 def test_allowed_missing_parent(self):
     v = DavView()
     parent = MissingMockCollection('/path/to/obj')
     v.__dict__['resource'] = MissingMockCollection(
         '/path/', get_parent=Mock(return_value=parent))
     self.assertListEqual(v._allowed_methods(), [
         'HEAD', 'OPTIONS', 'PROPFIND', 'LOCK', 'UNLOCK', 'GET', 'DELETE',
         'PROPPATCH', 'COPY', 'MOVE', 'PUT', 'MKCOL'
     ])
Exemplo n.º 2
0
 def setUp(self):
     self.blank_collection = MockCollection(
         path='/blank_collection/',
         get_descendants=Mock(return_value=[]),
         get_parent=lambda: self.top_collection
     )
     self.sub_object = MockObject(
         path='/collection/sub_object',
         getcontentlength=42,
         get_descendants=Mock(return_value=[]),
         get_parent=lambda: self.top_collection
     )
     self.missing_sub_object = MissingMockObject(
         path='/collection/missing_sub_object',
         getcontentlength=42,
         get_descendants=Mock(return_value=[]),
         get_parent=lambda: self.top_collection
     )
     self.missing_sub_collection = MissingMockCollection(
         path='/collection/missing_sub_collection',
         get_descendants=Mock(return_value=[]),
         get_parent=lambda: self.top_collection
     )
     self.sub_collection = MockCollection(
         path='/collection/sub_colection/',
         get_descendants=Mock(return_value=[]),
         get_parent=lambda: self.top_collection
     )
     self.top_collection = MockCollection(
         path='/collection/',
         get_descendants=Mock(return_value=[self.sub_object, self.sub_collection])
     )
Exemplo n.º 3
0
 def test_missing(self):
     path = '/object.mp4'
     r = DavView(path=path, acl_class=FullAcl)
     r.__dict__['resource'] = MissingMockCollection(path)
     request = Mock(META={'SERVERNANE': 'testserver'},
                    build_absolute_uri=Mock(return_value=path))
     self.assertRaises(Http404, r.get, request, path, 'xbody')
Exemplo n.º 4
0
    def test_copy_collection_depth_0(self):
        child = MockObject('/path/to/src/child', copy=Mock())
        src = MockCollection('/path/to/src/',
                             get_children=Mock(return_value=[child]),
                             delete=Mock())
        dst = MissingMockCollection('/path/to/dst/', create_collection=Mock())

        src.copy(dst, 0)

        dst.create_collection.assert_called_with()
        self.assertEqual(child.copy.call_count, 0)
Exemplo n.º 5
0
    def test_copy_collection(self):
        child = MockObject('/path/to/src/child', copy=Mock())
        src = MockCollection('/path/to/src/',
                             get_children=Mock(return_value=[child]),
                             delete=Mock())
        dst = MissingMockCollection('/path/to/dst/', create_collection=Mock())

        src.copy(dst)

        dst.create_collection.assert_called_with()
        self.assertEqual(child.copy.call_args[0][0].path,
                         ['path', 'to', 'dst', 'child'])
Exemplo n.º 6
0
 def test_allowed_missing_parent(self):
     v = DavView()
     parent = MissingMockCollection('/path/to/obj')
     v.__dict__['resource'] = MissingMockCollection(
         '/path/', get_parent=Mock(return_value=parent))
     self.assertEqual(v._allowed_methods(), [])