mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-18 22:44:10 +02:00
black formatting
This commit is contained in:
parent
1c9e21f9a2
commit
3dba2029b5
4 changed files with 84 additions and 62 deletions
|
|
@ -355,7 +355,10 @@ def test_add_foreign_key(fresh_db):
|
|||
assert isinstance(t, Table) and t.name == "books"
|
||||
assert [
|
||||
ForeignKey(
|
||||
table="books", column=("author_id",), other_table="authors", other_column=("id",)
|
||||
table="books",
|
||||
column=("author_id",),
|
||||
other_table="authors",
|
||||
other_column=("id",),
|
||||
)
|
||||
] == fresh_db["books"].foreign_keys
|
||||
|
||||
|
|
@ -364,9 +367,9 @@ def test_add_compound_foreign_key(fresh_db):
|
|||
fresh_db["authors"].insert_all(
|
||||
[
|
||||
{"id": 1, "person_id": 1, "name": "Sally"},
|
||||
{"id": 2, "person_id": 2, "name": "Asheesh"}
|
||||
{"id": 2, "person_id": 2, "name": "Asheesh"},
|
||||
],
|
||||
pk=("id", "person_id")
|
||||
pk=("id", "person_id"),
|
||||
)
|
||||
fresh_db["books"].insert_all(
|
||||
[
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ def test_extract_single_column(fresh_db, table, fk_column):
|
|||
" [name] TEXT,\n"
|
||||
" [{}] INTEGER,\n".format(expected_fk)
|
||||
+ " [end] INTEGER,\n"
|
||||
+ " FOREIGN KEY([{}]) REFERENCES [{}]([id])\n".format(expected_fk, expected_table)
|
||||
+ " FOREIGN KEY([{}]) REFERENCES [{}]([id])\n".format(
|
||||
expected_fk, expected_table
|
||||
)
|
||||
+ ")"
|
||||
)
|
||||
assert fresh_db[expected_table].schema == (
|
||||
|
|
|
|||
|
|
@ -30,17 +30,25 @@ def test_insert_m2m_list(fresh_db):
|
|||
assert [{"id": 1, "name": "Natalie D"}, {"id": 2, "name": "Simon W"}] == list(
|
||||
humans.rows
|
||||
)
|
||||
assert sorted([
|
||||
ForeignKey(
|
||||
table="dogs_humans", column="dogs_id", other_table="dogs", other_column="id"
|
||||
),
|
||||
ForeignKey(
|
||||
table="dogs_humans",
|
||||
column="humans_id",
|
||||
other_table="humans",
|
||||
other_column="id",
|
||||
),
|
||||
]) == sorted(dogs_humans.foreign_keys)
|
||||
assert (
|
||||
sorted(
|
||||
[
|
||||
ForeignKey(
|
||||
table="dogs_humans",
|
||||
column="dogs_id",
|
||||
other_table="dogs",
|
||||
other_column="id",
|
||||
),
|
||||
ForeignKey(
|
||||
table="dogs_humans",
|
||||
column="humans_id",
|
||||
other_table="humans",
|
||||
other_column="id",
|
||||
),
|
||||
]
|
||||
)
|
||||
== sorted(dogs_humans.foreign_keys)
|
||||
)
|
||||
|
||||
|
||||
def test_insert_m2m_iterable(fresh_db):
|
||||
|
|
@ -103,17 +111,25 @@ def test_m2m_lookup(fresh_db):
|
|||
tags = fresh_db["tags"]
|
||||
assert people_tags.exists()
|
||||
assert tags.exists()
|
||||
assert sorted([
|
||||
ForeignKey(
|
||||
table="people_tags",
|
||||
column="people_id",
|
||||
other_table="people",
|
||||
other_column="id",
|
||||
),
|
||||
ForeignKey(
|
||||
table="people_tags", column="tags_id", other_table="tags", other_column="id"
|
||||
),
|
||||
]) == sorted(people_tags.foreign_keys)
|
||||
assert (
|
||||
sorted(
|
||||
[
|
||||
ForeignKey(
|
||||
table="people_tags",
|
||||
column="people_id",
|
||||
other_table="people",
|
||||
other_column="id",
|
||||
),
|
||||
ForeignKey(
|
||||
table="people_tags",
|
||||
column="tags_id",
|
||||
other_table="tags",
|
||||
other_column="id",
|
||||
),
|
||||
]
|
||||
)
|
||||
== sorted(people_tags.foreign_keys)
|
||||
)
|
||||
assert [{"people_id": 1, "tags_id": 1}] == list(people_tags.rows)
|
||||
assert [{"id": 1, "name": "Wahyu"}] == list(people.rows)
|
||||
assert [{"id": 1, "tag": "Coworker"}] == list(tags.rows)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue