Skip to content

Commit c3ed67d

Browse files
committed
Ruff checks
1 parent a6cf640 commit c3ed67d

3 files changed

Lines changed: 2 additions & 127 deletions

File tree

filesender/download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def files_from_page(content: bytes) -> Iterable[DownloadFile]:
3535
"""
3636
for file in BeautifulSoup(content, "html.parser").find_all(class_="file"):
3737
yield {
38-
"client_entropy": file.attrs[f"data-client-entropy"],
38+
"client_entropy": file.attrs["data-client-entropy"],
3939
"encrypted": file.attrs["data-encrypted"],
4040
"encrypted_size": _opt_int(file.attrs["data-encrypted-size"]),
4141
"fileaead": file.attrs["data-fileaead"],

filesender/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
from importlib.metadata import version
1515
from rich.logging import RichHandler
1616
from filesender.log import LogParam, LogLevel, configure_extra_levels
17+
from filesender.response_types import Guest, Transfer
1718

1819
logger = logging.getLogger(__name__)
1920

20-
from filesender.response_types import Guest, Transfer
2121

2222
P = ParamSpec("P")
2323
T = TypeVar("T")

test/test_client.py

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -183,131 +183,6 @@ async def test_round_trip(base_url: str, username: str, apikey: str, recipient:
183183
assert count_files_recursively(Path(download_dir)) == 1
184184

185185

186-
@pytest.mark.asyncio
187-
async def test_round_trip_dir(
188-
base_url: str, username: str, apikey: str, recipient: str
189-
):
190-
"""
191-
This tests uploading two 1MB files in a directory
192-
"""
193-
194-
user_client = FileSenderClient(
195-
base_url=base_url, auth=UserAuth(api_key=apikey, username=username)
196-
)
197-
await user_client.prepare()
198-
199-
with tempfile.TemporaryDirectory() as tempdir:
200-
with make_tempfiles(size=1024**2, n=2, suffix=".dat", dir=tempdir):
201-
# The user uploads the entire directory
202-
transfer = await user_client.upload_workflow(
203-
files=[Path(tempdir)],
204-
transfer_args={"recipients": [recipient], "from": username},
205-
)
206-
207-
download_client = FileSenderClient(base_url=base_url)
208-
209-
with tempfile.TemporaryDirectory() as download_dir:
210-
await download_client.download_files(
211-
token=transfer["recipients"][0]["token"],
212-
out_dir=Path(download_dir),
213-
)
214-
assert count_files_recursively(Path(download_dir)) == 2
215-
216-
217-
@pytest.mark.asyncio
218-
@pytest.mark.parametrize("guest_opts", [{}, {"can_only_send_to_me": False}])
219-
async def test_voucher_round_trip(
220-
base_url: str, username: str, apikey: str, recipient: str, guest_opts: GuestOptions
221-
):
222-
"""
223-
This tests uploading a 1GB file, with ensures that the chunking behaviour is correct,
224-
but also the multithreaded uploading
225-
"""
226-
user_client = FileSenderClient(
227-
base_url=base_url, auth=UserAuth(api_key=apikey, username=username)
228-
)
229-
230-
# Invite the guest
231-
guest = await user_client.create_guest(
232-
{
233-
"recipient": recipient,
234-
"from": username,
235-
"options": {
236-
"guest": {
237-
# See https://github.com/filesender/filesender/issues/1889
238-
"can_only_send_to_me": True
239-
},
240-
},
241-
}
242-
)
243-
244-
guest_auth = GuestAuth(guest_token=guest["token"])
245-
guest_client = FileSenderClient(
246-
base_url=base_url,
247-
auth=guest_auth,
248-
)
249-
await guest_client.prepare()
250-
await guest_auth.prepare(guest_client.http_client)
251-
252-
with make_tempfile(size=1024**2, suffix=".dat") as path:
253-
# The guest uploads the file
254-
transfer = await guest_client.upload_workflow(
255-
files=[path],
256-
# FileSender will accept basically any recipients array here, but the argument can't be missing
257-
transfer_args={"recipients": []},
258-
)
259-
260-
with tempfile.TemporaryDirectory() as download_dir:
261-
# The user downloads the file
262-
await user_client.download_file(
263-
token=transfer["recipients"][0]["token"],
264-
file_id=transfer["files"][0]["id"],
265-
out_dir=Path(download_dir),
266-
)
267-
assert count_files_recursively(Path(download_dir)) == 1
268-
269-
270-
@pytest.mark.asyncio
271-
@pytest.mark.parametrize("guest_opts", [{}, {"can_only_send_to_me": False}])
272-
async def test_guest_creation(
273-
base_url: str, username: str, apikey: str, recipient: str, guest_opts: GuestOptions
274-
):
275-
user_client = FileSenderClient(
276-
base_url=base_url, auth=UserAuth(api_key=apikey, username=username)
277-
)
278-
279-
# Invite the guest
280-
guest = await user_client.create_guest(
281-
{"recipient": recipient, "from": username, "options": {"guest": guest_opts}}
282-
)
283-
284-
# Check that the options were acknowledged by the server
285-
for key, value in guest_opts.items():
286-
assert guest["options"][key] == value
287-
288-
289-
@pytest.mark.skip("This is inconsistent")
290-
@pytest.mark.asyncio
291-
async def test_upload_semaphore(
292-
base_url: str, username: str, apikey: str, recipient: str
293-
):
294-
"""
295-
Tests that limiting the concurrency of the client increases the runtime but decreases the memory usage
296-
"""
297-
with make_tempfiles(size=100_000_000, n=3) as paths:
298-
limited, unlimited = benchmark(
299-
paths,
300-
[1, float("inf")],
301-
[1, float("inf")],
302-
base_url,
303-
username,
304-
apikey,
305-
recipient,
306-
)
307-
assert unlimited.time < limited.time
308-
assert unlimited.memory > limited.memory
309-
310-
311186
@pytest.mark.asyncio
312187
async def test_client_download_url():
313188
"""

0 commit comments

Comments
 (0)