| 1 |
###################################################################### |
| 2 |
# |
| 3 |
# File: test/unit/console_tool/test_file_info.py |
| 4 |
# |
| 5 |
# Copyright 2023 Backblaze Inc. All Rights Reserved. |
| 6 |
# |
| 7 |
# License https://www.backblaze.com/using_b2_code.html |
| 8 |
# |
| 9 |
###################################################################### |
| 10 |
import pytest |
| 11 |
|
| 12 |
|
| 13 |
@pytest.fixture |
| 14 |
def uploaded_download_version(b2_cli, bucket_info, uploaded_file): |
| 15 |
return { |
| 16 |
"contentSha1": "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed", |
| 17 |
"contentType": "b2/x-auto", |
| 18 |
"fileId": uploaded_file["fileId"], |
| 19 |
"fileInfo": { |
| 20 |
"src_last_modified_millis": "1500111222000" |
| 21 |
}, |
| 22 |
"fileName": "file1.txt", |
| 23 |
"serverSideEncryption": { |
| 24 |
"mode": "none" |
| 25 |
}, |
| 26 |
"size": 11, |
| 27 |
"uploadTimestamp": 5000, |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
@pytest.fixture |
| 32 |
def uploaded_file_version(b2_cli, bucket_info, uploaded_file, uploaded_download_version): |
| 33 |
return { |
| 34 |
**uploaded_download_version, |
| 35 |
"accountId": b2_cli.account_id, |
| 36 |
"action": "upload", |
| 37 |
"bucketId": uploaded_file["bucketId"], |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
def test_get_file_info(b2_cli, uploaded_file_version): |
| 42 |
b2_cli.run( |
| 43 |
["get-file-info", uploaded_file_version["fileId"]], |
| 44 |
expected_json_in_stdout=uploaded_file_version, |
| 45 |
expected_stderr='WARNING: get-file-info command is deprecated. Use file-info instead.\n', |
| 46 |
) |
| 47 |
|
| 48 |
|
| 49 |
def test_file_info__b2_uri(b2_cli, bucket, uploaded_download_version): |
| 50 |
b2_cli.run( |
| 51 |
[ |
| 52 |
"file-info", |
| 53 |
f'b2://{bucket}/{uploaded_download_version["fileName"]}', |
| 54 |
], |
| 55 |
expected_json_in_stdout=uploaded_download_version, |
| 56 |
) |
| 57 |
|
| 58 |
|
| 59 |
def test_file_info__b2id_uri(b2_cli, uploaded_file_version): |
| 60 |
b2_cli.run( |
| 61 |
["file-info", f'b2id://{uploaded_file_version["fileId"]}'], |
| 62 |
expected_json_in_stdout=uploaded_file_version, |
| 63 |
) |