File tree Expand file tree Collapse file tree 3 files changed +32
-23
lines changed
Expand file tree Collapse file tree 3 files changed +32
-23
lines changed Original file line number Diff line number Diff line change 1+ import io
12import os
3+ import zipfile
24
35from dotenv import load_dotenv
46
57import squarecloud
68
79load_dotenv ()
810client = squarecloud .Client (os .getenv ('KEY' ))
11+
12+
13+ def create_zip (include_squarecloud_app : bool = True ):
14+ buffer = io .BytesIO ()
15+
16+ with zipfile .ZipFile (buffer , 'w' ) as zip_file :
17+ zip_file .write (
18+ r'tests\test_upload\requirements.txt' , 'requirements.txt'
19+ )
20+
21+ zip_file .write (r'tests\test_upload\main.py' , 'main.py' )
22+
23+ if include_squarecloud_app :
24+ zip_file .write (
25+ r'tests\test_upload\squarecloud.app' , 'squarecloud.app'
26+ )
27+
28+ buffer .seek (0 )
29+
30+ return buffer .getvalue ()
Original file line number Diff line number Diff line change 11import pytest
2+ import squarecloud
23
34from squarecloud import Endpoint , File
45from squarecloud .data import UploadData
56from squarecloud .http import Response
67
7- from . import client
8+ from . import client , create_zip
89
910
1011@pytest .mark .asyncio
@@ -16,8 +17,14 @@ async def test_upload(self):
1617 async def test (response : Response ):
1718 assert isinstance (response , Response )
1819
20+ squarecloud .create_config_file (
21+ r'tests\test_upload' ,
22+ display_name = 'normal_test' ,
23+ main = 'main.py' ,
24+ memory = 100 ,
25+ )
1926 upload_data : UploadData = await client .upload_app (
20- File ('tests/test_upload/test_normal_upload .zip' )
27+ File (create_zip (), filename = 'file .zip' )
2128 )
2229 TestRequestListeners .APP_ID = upload_data .id
2330
Original file line number Diff line number Diff line change 88from squarecloud import File , errors
99from squarecloud .data import UploadData
1010
11- from . import client
12-
13-
14- def create_zip (include_squarecloud_app : bool = True ):
15- buffer = io .BytesIO ()
16-
17- with zipfile .ZipFile (buffer , 'w' ) as zip_file :
18- zip_file .write (
19- r'tests\test_upload\requirements.txt' , 'requirements.txt'
20- )
21-
22- zip_file .write (r'tests\test_upload\main.py' , 'main.py' )
23-
24- if include_squarecloud_app :
25- zip_file .write (
26- r'tests\test_upload\squarecloud.app' , 'squarecloud.app'
27- )
28-
29- buffer .seek (0 )
30-
31- return buffer .getvalue ()
11+ from . import client , create_zip
3212
3313
3414@pytest .mark .asyncio
You can’t perform that action at this time.
0 commit comments