autotako

Service to monitor moombox for completed livestream downloads to upload for distribution
git clone https://code.alwayswait.ing/autotako
Log | Files | Refs | README

test_webdav_upload.py (895B)


      1 #!/usr/bin/python3
      2 
      3 import secrets
      4 import urllib
      5 
      6 import httpx
      7 import pytest
      8 from autotako.job_render import do_webdav_upload
      9 
     10 
     11 @pytest.mark.asyncio
     12 @pytest.mark.webdav
     13 async def test_webdav_upload(webdav_test_config, tmp_path):
     14     webdav = webdav_test_config.webdav
     15     test_path = webdav_test_config.path
     16 
     17     buffer = secrets.token_bytes(4096)
     18 
     19     auth = httpx.BasicAuth(username=webdav.username, password=webdav.password)
     20     async with httpx.AsyncClient(auth=auth) as webclient:
     21         await webclient.delete(urllib.parse.urljoin(webdav.base_url, test_path))
     22 
     23         tf = tmp_path / "test.bin"
     24         tf.write_bytes(buffer)
     25         await do_webdav_upload(webdav, tf, test_path)
     26 
     27         resp = await webclient.get(urllib.parse.urljoin(webdav.base_url, test_path))
     28 
     29         assert buffer == resp.content
     30 
     31         await webclient.delete(urllib.parse.urljoin(webdav.base_url, test_path))