|
1 | 1 | import os
|
2 | 2 | import typing as t
|
| 3 | +from datetime import datetime |
3 | 4 | from random import choice, sample
|
4 | 5 |
|
5 | 6 | import pytest
|
|
9 | 10 | from sqlalchemy import Connection, Engine, Inspector, create_engine, inspect
|
10 | 11 |
|
11 | 12 | from mysql_to_sqlite3 import MySQLtoSQLite
|
| 13 | +from mysql_to_sqlite3 import __version__ as package_version |
12 | 14 | from mysql_to_sqlite3.cli import cli as mysql2sqlite
|
13 | 15 | from tests.conftest import MySQLCredentials
|
14 | 16 | from tests.database import Database
|
|
19 | 21 | class TestMySQLtoSQLite:
|
20 | 22 | def test_no_arguments(self, cli_runner: CliRunner) -> None:
|
21 | 23 | result: Result = cli_runner.invoke(mysql2sqlite)
|
22 |
| - assert result.exit_code > 0 |
23 |
| - assert any( |
| 24 | + assert result.exit_code == 0 |
| 25 | + assert all( |
24 | 26 | message in result.output
|
25 | 27 | for message in {
|
26 |
| - 'Error: Missing option "-f" / "--sqlite-file"', |
27 |
| - "Error: Missing option '-f' / '--sqlite-file'", |
| 28 | + f"Usage: {mysql2sqlite.name} [OPTIONS]", |
| 29 | + f"{mysql2sqlite.name} version {package_version} Copyright (c) 2019-{datetime.now().year} Klemen Tusar", |
28 | 30 | }
|
29 | 31 | )
|
30 | 32 |
|
@@ -332,10 +334,14 @@ def test_minimum_valid_parameters(
|
332 | 334 | arguments.append("-q")
|
333 | 335 | result: Result = cli_runner.invoke(mysql2sqlite, arguments)
|
334 | 336 | assert result.exit_code == 0
|
| 337 | + copyright_header = ( |
| 338 | + f"{mysql2sqlite.name} version {package_version} Copyright (c) 2019-{datetime.now().year} Klemen Tusar\n" |
| 339 | + ) |
| 340 | + assert copyright_header in result.output |
335 | 341 | if quiet:
|
336 |
| - assert result.output == "" |
| 342 | + assert result.output.replace(copyright_header, "") == "" |
337 | 343 | else:
|
338 |
| - assert result.output != "" |
| 344 | + assert result.output.replace(copyright_header, "") != "" |
339 | 345 |
|
340 | 346 | def test_keyboard_interrupt(
|
341 | 347 | self,
|
|
0 commit comments