Skip to content

Commit da92a30

Browse files
committed
Test for insert CLI with multiple --pk, refs #621
1 parent 23be5be commit da92a30

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/test_cli_insert.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,24 @@ def test_insert_json_flatten_nl(tmpdir):
7777
]
7878

7979

80-
def test_insert_with_primary_key(db_path, tmpdir):
80+
@pytest.mark.parametrize(
81+
"args,expected_pks",
82+
(
83+
(["--pk", "id"], ["id"]),
84+
(["--pk", "id", "--pk", "name"], ["id", "name"]),
85+
),
86+
)
87+
def test_insert_with_primary_keys(db_path, tmpdir, args, expected_pks):
8188
json_path = str(tmpdir / "dog.json")
8289
with open(json_path, "w") as fp:
8390
fp.write(json.dumps({"id": 1, "name": "Cleo", "age": 4}))
84-
result = CliRunner().invoke(
85-
cli.cli, ["insert", db_path, "dogs", json_path, "--pk", "id"]
86-
)
91+
result = CliRunner().invoke(cli.cli, ["insert", db_path, "dogs", json_path] + args)
8792
assert result.exit_code == 0
8893
assert [{"id": 1, "age": 4, "name": "Cleo"}] == list(
8994
Database(db_path).query("select * from dogs")
9095
)
9196
db = Database(db_path)
92-
assert ["id"] == db["dogs"].pks
97+
assert db["dogs"].pks == expected_pks
9398

9499

95100
def test_insert_multiple_with_primary_key(db_path, tmpdir):

0 commit comments

Comments
 (0)