python-caldav / caldav

Apache License 2.0
314 stars 94 forks source link

test_caldav_unit fails for tag 1.3.3 #320

Closed fauxmight closed 1 year ago

fauxmight commented 1 year ago
============================= test session starts ==============================
platform linux -- Python 3.11.3, pytest-7.4.0, pluggy-1.0.0
rootdir: /tmp/aur/python-caldav/src/caldav-1.3.3
plugins: cov-4.1.0
collected 117 items

tests/test_caldav.py s.s..s..s...........ss..............s....s......... [ 43%]
.........s...............s..                                             [ 67%]
tests/test_caldav_unit.py .................F...........                  [ 92%]
tests/test_cdav.py ......                                                [ 97%]
tests/test_utils.py .                                                    [ 98%]
tests/test_vcal.py ..                                                    [100%]

=================================== FAILURES ===================================
_________________________ TestCalDAV.testHugeTreeParam _________________________

self = <tests.test_caldav_unit.TestCalDAV object at 0x7f247a9427d0>

        def testHugeTreeParam(self):
            """
            With dealing with a huge XML response, such as event containing attachments, XMLParser will throw an exception
            huge_tree parameters allows to handle this kind of events.
            """

            xml = """
    <multistatus xmlns="DAV:">
      <response>
        <href>/17149682/calendars/testcalendar-84439d0b-ce46-4416-b978-7b4009122c64/</href>
        <propstat>
          <prop>
                    </prop>
          <status>HTTP/1.1 200 OK</status>
        </propstat>
        <propstat>
          <prop>
            <calendar-data xmlns="urn:ietf:params:xml:ns:caldav"/>
          </prop>
          <status>HTTP/1.1 404 Not Found</status>
        </propstat>
      </response>
      <response>
        <href>/17149682/calendars/testcalendar-84439d0b-ce46-4416-b978-7b4009122c64/20010712T182145Z-123401%40example.com.ics</href>
        <propstat>
          <prop>
            <calendar-data xmlns="urn:ietf:params:xml:ns:caldav">

    BEGIN:VCALENDAR
    PRODID:-//MDaemon Technologies Ltd//MDaemon 21.5.2
    VERSION:2.0
    METHOD:PUBLISH
    BEGIN:VEVENT
    UID:
     040000008200E0007000B7101A82E0080000000050BF99B19D31
    SEQUENCE:0
    DTSTAMP:20230213T142930Z
    SUMMARY:This a summary of a very bug event
    DESCRIPTION:Description of this very big event
    LOCATION:Somewhere
    ORGANIZER:MAILTO:noreply@test.com
    PRIORITY:5
    ATTACH;VALUE=BINARY;ENCODING=BASE64;FMTTYPE=image/jpeg;
     X-FILENAME=image001.jpg;X-ORACLE-FILENAME=image001.jpg:
    """
            xml += (
                "gIyIoLTkwKCo2KyIjM4444449QEBAJjBGS0U+Sjk/QD3/2wBDAQsLCw8NDx0QEB09KSMpPT09\n"
                * 153490
            )
            xml += """
     /Z
    DTSTART;TZID="Europe/Paris":20230310T140000
    DTEND;TZID="Europe/Paris":20230310T150000
    END:VEVENT
    END:VCALENDAR
    </calendar-data>
          </prop>
          <status>HTTP/1.1 200 OK</status>
        </propstat>
      </response>
    </multistatus>
    """
            davclient = MockedDAVClient(xml)
            resp = mock.MagicMock()
            resp.headers = {"Content-Type": "text/xml"}
            resp.content = xml

            davclient.huge_tree = False
            try:
                DAVResponse(resp, davclient=davclient)
>               assert False
E               assert False

tests/test_caldav_unit.py:955: AssertionError

During handling of the above exception, another exception occurred:

self = <tests.test_caldav_unit.TestCalDAV object at 0x7f247a9427d0>

        def testHugeTreeParam(self):
            """
            With dealing with a huge XML response, such as event containing attachments, XMLParser will throw an exception
            huge_tree parameters allows to handle this kind of events.
            """

            xml = """
    <multistatus xmlns="DAV:">
      <response>
        <href>/17149682/calendars/testcalendar-84439d0b-ce46-4416-b978-7b4009122c64/</href>
        <propstat>
          <prop>
                    </prop>
          <status>HTTP/1.1 200 OK</status>
        </propstat>
        <propstat>
          <prop>
            <calendar-data xmlns="urn:ietf:params:xml:ns:caldav"/>
          </prop>
          <status>HTTP/1.1 404 Not Found</status>
        </propstat>
      </response>
      <response>
        <href>/17149682/calendars/testcalendar-84439d0b-ce46-4416-b978-7b4009122c64/20010712T182145Z-123401%40example.com.ics</href>
        <propstat>
          <prop>
            <calendar-data xmlns="urn:ietf:params:xml:ns:caldav">

    BEGIN:VCALENDAR
    PRODID:-//MDaemon Technologies Ltd//MDaemon 21.5.2
    VERSION:2.0
    METHOD:PUBLISH
    BEGIN:VEVENT
    UID:
     040000008200E0007000B7101A82E0080000000050BF99B19D31
    SEQUENCE:0
    DTSTAMP:20230213T142930Z
    SUMMARY:This a summary of a very bug event
    DESCRIPTION:Description of this very big event
    LOCATION:Somewhere
    ORGANIZER:MAILTO:noreply@test.com
    PRIORITY:5
    ATTACH;VALUE=BINARY;ENCODING=BASE64;FMTTYPE=image/jpeg;
     X-FILENAME=image001.jpg;X-ORACLE-FILENAME=image001.jpg:
    """
            xml += (
                "gIyIoLTkwKCo2KyIjM4444449QEBAJjBGS0U+Sjk/QD3/2wBDAQsLCw8NDx0QEB09KSMpPT09\n"
                * 153490
            )
            xml += """
     /Z
    DTSTART;TZID="Europe/Paris":20230310T140000
    DTEND;TZID="Europe/Paris":20230310T150000
    END:VEVENT
    END:VCALENDAR
    </calendar-data>
          </prop>
          <status>HTTP/1.1 200 OK</status>
        </propstat>
      </response>
    </multistatus>
    """
            davclient = MockedDAVClient(xml)
            resp = mock.MagicMock()
            resp.headers = {"Content-Type": "text/xml"}
            resp.content = xml

            davclient.huge_tree = False
            try:
                DAVResponse(resp, davclient=davclient)
                assert False
            except Exception as e:
>               assert type(e) == lxml.etree.XMLSyntaxError
E               AssertionError: assert <class 'AssertionError'> == <class 'lxml.etree.XMLSyntaxError'>
E                +  where <class 'AssertionError'> = type(AssertionError('assert False'))
E                +  and   <class 'lxml.etree.XMLSyntaxError'> = <module 'lxml.etree' from '/usr/lib/python3.11/site-packages/lxml/etree.cpython-311-x86_64-linux-gnu.so'>.XMLSyntaxError
E                +    where <module 'lxml.etree' from '/usr/lib/python3.11/site-packages/lxml/etree.cpython-311-x86_64-linux-gnu.so'> = lxml.etree

tests/test_caldav_unit.py:957: AssertionError
=========================== short test summary info ============================
FAILED tests/test_caldav_unit.py::TestCalDAV::testHugeTreeParam - AssertionEr...
================== 1 failed, 106 passed, 10 skipped in 16.10s ==================
tobixen commented 1 year ago

Huh ... it passes on github, perhaps some versioning problems with the lxml module? I'll look into it.

tobixen commented 1 year ago

1.3.4 has been released

tobixen commented 1 year ago

Oh noes ... I was too quick and broke the style test. There will be a 1.3.5 soon. (I thought I configured github so that it should not merge pull requests unless all tests passed ... weird)