initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from evanescere.services.webdav import WebDavFile, has_stable_size, parse_propfind_response
|
||||
|
||||
|
||||
class DummyVideo:
|
||||
def __init__(self, samples):
|
||||
self.size_samples = samples
|
||||
|
||||
|
||||
def test_has_stable_size_requires_two_equal_positive_samples():
|
||||
assert not has_stable_size(DummyVideo([]))
|
||||
assert not has_stable_size(DummyVideo([{"size_bytes": 100}]))
|
||||
assert not has_stable_size(DummyVideo([{"size_bytes": 100}, {"size_bytes": 101}]))
|
||||
assert has_stable_size(DummyVideo([{"size_bytes": 100}, {"size_bytes": 100}]))
|
||||
|
||||
|
||||
def test_parse_propfind_response_filters_video_files():
|
||||
xml = """<?xml version="1.0"?>
|
||||
<D:multistatus xmlns:D="DAV:">
|
||||
<D:response>
|
||||
<D:href>/webdav/recordings/</D:href>
|
||||
<D:propstat><D:prop><D:resourcetype><D:collection/></D:resourcetype></D:prop></D:propstat>
|
||||
</D:response>
|
||||
<D:response>
|
||||
<D:href>/webdav/recordings/stream.flv</D:href>
|
||||
<D:propstat><D:prop><D:getcontentlength>123</D:getcontentlength></D:prop></D:propstat>
|
||||
</D:response>
|
||||
<D:response>
|
||||
<D:href>/webdav/recordings/readme.txt</D:href>
|
||||
<D:propstat><D:prop><D:getcontentlength>12</D:getcontentlength></D:prop></D:propstat>
|
||||
</D:response>
|
||||
</D:multistatus>"""
|
||||
assert parse_propfind_response(xml, "https://host/webdav/recordings") == [
|
||||
WebDavFile("https://host/webdav/recordings/stream.flv", "stream.flv", 123, None)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user