(
tmp_path: pathlib.Path,
cli_runner: CliRunner,
mock_config: Config,
httpx_mock: HTTPXMock,
mock_private_key: PrivateKey,
mocker: MockFixture,
)
| 89 | |
| 90 | |
| 91 | def test_dump( |
| 92 | tmp_path: pathlib.Path, |
| 93 | cli_runner: CliRunner, |
| 94 | mock_config: Config, |
| 95 | httpx_mock: HTTPXMock, |
| 96 | mock_private_key: PrivateKey, |
| 97 | mocker: MockFixture, |
| 98 | ): |
| 99 | mock_decrypt_file = mocker.patch("beanhub_cli.encryption.decrypt_file") |
| 100 | mock_extract_inbox_tar = mocker.patch("beanhub_cli.file_io.extract_inbox_tar") |
| 101 | |
| 102 | emails = [ |
| 103 | InboxEmailFactory(id="email0"), |
| 104 | InboxEmailFactory(id="email1"), |
| 105 | InboxEmailFactory(id="email2"), |
| 106 | InboxEmailFactory(id="email3"), |
| 107 | InboxEmailFactory(id="email4"), |
| 108 | ] |
| 109 | inbox_doc = InboxDoc( |
| 110 | inbox=[ |
| 111 | InboxConfig( |
| 112 | action=ArchiveInboxAction(output_file="inbox-data/default/{{ id }}.eml") |
| 113 | ) |
| 114 | ] |
| 115 | ) |
| 116 | inbox_doc_path = tmp_path / ".beanhub" / "inbox.yaml" |
| 117 | inbox_doc_path.parent.mkdir(exist_ok=True, parents=True) |
| 118 | inbox_doc_path.write_text(inbox_doc.model_dump_json()) |
| 119 | existing_files = [ |
| 120 | emails[1].id, |
| 121 | ] |
| 122 | for existing_file in existing_files: |
| 123 | existing_file_path = tmp_path / existing_file |
| 124 | existing_file_path.parent.mkdir(parents=True, exist_ok=True) |
| 125 | existing_file_path.write_text("") |
| 126 | |
| 127 | dump_id = uuid.uuid4() |
| 128 | public_key = mock_private_key.public_key.encode(URLSafeBase64Encoder).decode( |
| 129 | "ascii" |
| 130 | ) |
| 131 | mock_download_url = "https://example.com/download" |
| 132 | box = SealedBox(mock_private_key) |
| 133 | encryption_key = box.encrypt( |
| 134 | json.dumps( |
| 135 | dict( |
| 136 | key=URLSafeBase64Encoder.encode(b"MOCK_KEY").decode("ascii"), |
| 137 | iv=URLSafeBase64Encoder.encode(b"MOCK_IV").decode("ascii"), |
| 138 | ) |
| 139 | ).encode("ascii"), |
| 140 | encoder=URLSafeBase64Encoder, |
| 141 | ).decode("ascii") |
| 142 | |
| 143 | httpx_mock.add_response( |
| 144 | url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/inbox/emails", |
| 145 | method="GET", |
| 146 | status_code=200, |
| 147 | json=dict( |
| 148 | emails=[ |
nothing calls this directly
no test coverage detected