~bzr/bzr-webdav/webdav

« back to all changes in this revision

Viewing changes to test_webdav.py

  • Committer: Vincent Ladeuil
  • Date: 2008-06-08 22:35:42 UTC
  • Revision ID: v.ladeuil+lp@free.fr-20080608223542-c47y2fmxuj9jngyy
All bzr tests passing with an apache2-dav local test server.

* test_webdav.py:
(_get_list_dir_apache2_depth_1_allprop): Tweak the the example by
putting non-zero lengths.
(TestDavSaxParser.test_list_dir_apache2_dir_depth_1_example):
<cough> add the forgotten test, we need to test for correct
behaviour and we re-factored two commits ago to do that don't we ?
(TestDavSaxParser.test_stat_apache2_dir_depth_0_example): Update
test '-1' for directory size is as good as None.

* webdav.py:
(DavStatHandler._init_response_attrs): Use '-1' for default length
value instead of None.
(DavStatHandler.endElement): Convert the length to int.
(_extract_dir_content): Return the full tuple instead of just the
name.
(HttpDavTransport.list_dir): Delegate to _list_tree and filter the
result.
(HttpDavTransport._list_tree): Was list_dir but now accept an
additional depth parameter.
(HttpDavTransport.iter_files_recursive): New function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
483
483
            <D:prop>
484
484
                <lp1:resourcetype/>
485
485
                <lp1:creationdate>2008-06-08T09:50:15Z</lp1:creationdate>
486
 
                <lp1:getcontentlength>0</lp1:getcontentlength>
 
486
                <lp1:getcontentlength>14</lp1:getcontentlength>
487
487
                <lp1:getlastmodified>Sun, 08 Jun 2008 09:50:11 GMT</lp1:getlastmodified>
488
488
                <lp1:getetag>"da9f81-0-9ef33ac0"</lp1:getetag>
489
489
                <lp2:executable>T</lp2:executable>
508
508
            <D:prop>
509
509
                <lp1:resourcetype/>
510
510
                <lp1:creationdate>2008-06-08T09:50:11Z</lp1:creationdate>
511
 
                <lp1:getcontentlength>0</lp1:getcontentlength>
 
511
                <lp1:getcontentlength>42</lp1:getcontentlength>
512
512
                <lp1:getlastmodified>Sun, 08 Jun 2008 09:50:11 GMT</lp1:getlastmodified>
513
513
                <lp1:getetag>"da9f80-0-9ef33ac0"</lp1:getetag>
514
514
                <lp2:executable>F</lp2:executable>
640
640
        self.assertRaises(errors.NotADirectory,
641
641
                         self._extract_dir_content_from_str, example)
642
642
 
 
643
    def test_list_dir_apache2_dir_depth_1_example(self):
 
644
        example = _get_list_dir_apache2_depth_1_allprop()
 
645
        self.assertEquals([('executable', False, 14, True),
 
646
                           ('read-only', False, 42, False),
 
647
                           ('titi', False, 6, False),
 
648
                           ('toto', True, -1, False)],
 
649
                          self._extract_dir_content_from_str(example))
 
650
 
643
651
    def test_stat_malformed_response(self):
644
652
        # Invalid xml, neither multistatus nor response are properly closed
645
653
        example = """<?xml version="1.0" encoding="utf-8"?>
732
740
</D:multistatus>
733
741
"""
734
742
        st = self._extract_stat_from_str(example)
735
 
        self.assertEquals(None, st.st_size)
 
743
        self.assertEquals(-1, st.st_size)
736
744
        self.assertTrue(stat.S_ISDIR(st.st_mode))
737
745
        self.assertTrue(st.st_mode & stat.S_IXUSR)