@@ -77,19 +77,24 @@ def test_insert_json_flatten_nl(tmpdir):
77
77
]
78
78
79
79
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 ):
81
88
json_path = str (tmpdir / "dog.json" )
82
89
with open (json_path , "w" ) as fp :
83
90
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 )
87
92
assert result .exit_code == 0
88
93
assert [{"id" : 1 , "age" : 4 , "name" : "Cleo" }] == list (
89
94
Database (db_path ).query ("select * from dogs" )
90
95
)
91
96
db = Database (db_path )
92
- assert [ "id" ] == db ["dogs" ].pks
97
+ assert db ["dogs" ].pks == expected_pks
93
98
94
99
95
100
def test_insert_multiple_with_primary_key (db_path , tmpdir ):
0 commit comments