Exemple #1
0
class ExtendedWebDAVClientTestCase(unittest.TestCase):
    """Test the ExtendedWebDAVClient class."""
    def setUp(self):
        """Setup the client."""
        self.dav = ExtendedWebDAVClient("127.0.0.1", 80)
        self.dav.setbasicauth("test", "passwd")
        self.con = Mock.HTTPConnection()
        self.dav._getconnection = lambda: self.con

    def test_report(self):
        """Test ExtendedWebDAVClient.report."""
        self.con.response.status = 207
        self.con.response.content = REPORT
        props = ["version-name", "creator-displayname", "successor-set"]
        response = self.dav.report("/foo.html", properties=props)
        self.assertEqual(response, 207)
        self.assertEqual(self.con.method, "REPORT")
        self.assertEqual(self.con.path, "/foo.html")
        self.assertEqual(self.con.headers["Depth"], "0")
        self.assertTrue(self.con.closed)
        self.assertTrue("Authorization" in self.con.headers)

    def test_report_depth_1(self):
        """Test ExtendedWebDAVClient.report with depth 1."""
        self.con.response.status = 207
        self.con.response.content = REPORT
        props = ["version-name", "creator-displayname", "successor-set"]
        response = self.dav.report("/foo.html", "1", props)
        self.assertEqual(response, 207)
        self.assertEqual(self.con.method, "REPORT")
        self.assertEqual(self.con.path, "/foo.html")
        self.assertEqual(self.con.headers["Depth"], "1")
        self.assertTrue(self.con.closed)
        self.assertTrue("Authorization" in self.con.headers)

    def test_report_illegal_depth(self):
        """Test ExtendedWebDAVClient.report with illegal depth."""
        # prepare mock connection
        self.assertRaises(ValueError, self.dav.report, "/foo.html", "ABC")
Exemple #2
0
 def setUp(self):
     """Setup the client."""
     self.dav = ExtendedWebDAVClient("127.0.0.1", 80)
     self.dav.setbasicauth(b"test", b"passwd")
     self.con = Mock.HTTPConnection()
     self.dav._getconnection = lambda: self.con
Exemple #3
0
class ExtendedWebDAVClientTestCase(unittest.TestCase):
    """Test the ExtendedWebDAVClient class."""
    def setUp(self):
        """Setup the client."""
        self.dav = ExtendedWebDAVClient("127.0.0.1", 80)
        self.dav.setbasicauth(b"test", b"passwd")
        self.con = Mock.HTTPConnection()
        self.dav._getconnection = lambda: self.con

    def test_version_tree_report_is_report(self):
        """Test ExtendedWebDAVClient.report."""
        assert self.dav.version_tree_report == self.dav.report

    def test_version_tree_report(self):
        """Test ExtendedWebDAVClient.version_tree_report."""
        self.con.response.status = 207
        self.con.response.content = REPORT
        props = ["version-name", "creator-displayname", "successor-set"]
        response = self.dav.version_tree_report("/foo.html", properties=props)
        assert response == 207
        assert self.con.method == "REPORT"
        assert self.con.path == "/foo.html"
        assert self.con.headers["Depth"] == "0"
        assert self.con.closed
        assert "Authorization" in self.con.headers

    def test_version_tree_report_depth_1(self):
        """Test ExtendedWebDAVClient.version_tree_report with depth 1."""
        self.con.response.status = 207
        self.con.response.content = REPORT
        props = ["version-name", "creator-displayname", "successor-set"]
        response = self.dav.version_tree_report("/foo.html", "1", props)
        assert response == 207
        assert self.con.method == "REPORT"
        assert self.con.path == "/foo.html"
        assert self.con.headers["Depth"] == "1"
        assert self.con.closed
        assert "Authorization" in self.con.headers

    def test_version_tree_report_illegal_depth(self):
        """Test ExtendedWebDAVClient.version_tree_report with illegal depth."""
        # prepare mock connection
        with pytest.raises(ValueError):
            self.dav.version_tree_report("/foo.html", "ABC")

    def test_expand_property_report(self):
        """Test ExtendedWebDAVClient.expand_property_report."""
        self.con.response.status = 207
        self.con.response.content = REPORT
        props = ["version-name", "creator-displayname", "successor-set"]
        response = self.dav.expand_property_report("/foo.html",
                                                   properties=props)
        assert response == 207
        assert self.con.method == "REPORT"
        assert self.con.path == "/foo.html"
        assert self.con.headers["Depth"] == "0"
        assert self.con.closed
        assert "Authorization" in self.con.headers

    def test_expand_property_report_depth_1(self):
        """Test ExtendedWebDAVClient.expand_property_report with depth 1."""
        self.con.response.status = 207
        self.con.response.content = REPORT
        props = ["version-name", "creator-displayname", "successor-set"]
        response = self.dav.expand_property_report("/foo.html", "1", props)
        assert response == 207
        assert self.con.method == "REPORT"
        assert self.con.path == "/foo.html"
        assert self.con.headers["Depth"] == "1"
        assert self.con.closed
        assert "Authorization" in self.con.headers

    def test_expand_property_report_illegal_depth(self):
        """Test ExtendedWebDAVClient.expand_property_report with illegal depth."""
        # prepare mock connection
        with pytest.raises(ValueError):
            self.dav.expand_property_report("/foo.html", "ABC")
Exemple #4
0
 def setUp(self):
     """Setup the client."""
     self.dav = ExtendedWebDAVClient("127.0.0.1", 80)
     self.dav.setbasicauth("test", "passwd")
     self.con = Mock.HTTPConnection()
     self.dav._getconnection = lambda: self.con