-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_objects.py
36 lines (34 loc) · 1007 Bytes
/
test_objects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from click.testing import CliRunner
from sqlite_diffable import cli
import pytest
@pytest.mark.parametrize(
"options,expected_output",
(
(
[],
(
'\n{"id": 1, "name": "Stacey"}\n'
'{"id": 2, "name": "Tilda"}\n'
'{"id": 3, "name": "Bartek"}\n'
),
),
(
["--array"],
(
'[\n{"id": 1, "name": "Stacey"},\n'
'{"id": 2, "name": "Tilda"},\n'
'{"id": 3, "name": "Bartek"}\n]\n'
),
),
),
)
def test_dump(one_table_db, tmpdir, options, expected_output):
output_dir = tmpdir / "out"
result = CliRunner().invoke(
cli.cli, ["dump", one_table_db, str(output_dir), "one_table"]
)
assert result.exit_code == 0, result.output
result2 = CliRunner().invoke(
cli.cli, ["objects", str(output_dir / "one_table.ndjson")] + options
)
assert result2.output == expected_output