FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlc-gen-python/examples/src/tests/test_booktest.py at main · sqlc-dev/sqlc-gen-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
sqlc-dev
/
sqlc-gen-python
Public
Notifications
You must be signed in to change notification settings
Fork
50
Star
337
Code
Issues
36
Pull requests
17
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlc-gen-python
/
examples
/
src
/
tests
/
test_booktest.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (69 loc) · 2.68 KB
Breadcrumbs
sqlc-gen-python
/
examples
/
src
/
tests
/
test_booktest.py
Copy path
File metadata and controls
85 lines (69 loc) · 2.68 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import
datetime
import
os
import
pytest
import
sqlalchemy
.
ext
.
asyncio
from
booktest
import
query
,
models
from
dbtest
.
migrations
import
apply_migrations_async
@
pytest
.
mark
.
asyncio
async
def
test_books
(
async_db
:
sqlalchemy
.
ext
.
asyncio
.
AsyncConnection
):
await
apply_migrations_async
(
async_db
, [
os
.
path
.
dirname
(
__file__
)
+
"/../booktest/schema.sql"
])
querier
=
query
.
AsyncQuerier
(
async_db
)
author
=
await
querier
.
create_author
(
name
=
"Unknown Master"
)
assert
author
is
not
None
now
=
datetime
.
datetime
.
now
()
await
querier
.
create_book
(
query
.
CreateBookParams
(
author_id
=
author
.
author_id
,
isbn
=
"1"
,
title
=
"my book title"
,
book_type
=
models
.
BookType
.
FICTION
,
year
=
2016
,
available
=
now
,
tags
=
[],
))
b1
=
await
querier
.
create_book
(
query
.
CreateBookParams
(
author_id
=
author
.
author_id
,
isbn
=
"2"
,
title
=
"the second book"
,
book_type
=
models
.
BookType
.
FICTION
,
year
=
2016
,
available
=
now
,
tags
=
[
"cool"
,
"unique"
],
))
await
querier
.
update_book
(
book_id
=
b1
.
book_id
,
title
=
"changed second title"
,
tags
=
[
"cool"
,
"disastor"
])
b3
=
await
querier
.
create_book
(
query
.
CreateBookParams
(
author_id
=
author
.
author_id
,
isbn
=
"3"
,
title
=
"the third book"
,
book_type
=
models
.
BookType
.
FICTION
,
year
=
2001
,
available
=
now
,
tags
=
[
"cool"
],
))
b4
=
await
querier
.
create_book
(
query
.
CreateBookParams
(
author_id
=
author
.
author_id
,
isbn
=
"4"
,
title
=
"4th place finisher"
,
book_type
=
models
.
BookType
.
NONFICTION
,
year
=
2011
,
available
=
now
,
tags
=
[
"other"
],
))
await
querier
.
update_book_isbn
(
book_id
=
b4
.
book_id
,
isbn
=
"NEW ISBN"
,
title
=
"never ever gonna finish, a quatrain"
,
tags
=
[
"someother"
])
books0
=
querier
.
books_by_title_year
(
title
=
"my book title"
,
year
=
2016
)
expected_titles
=
{
"my book title"
}
async
for
book
in
books0
:
expected_titles
.
remove
(
book
.
title
)
# raises a key error if the title does not exist
assert
len
(
book
.
tags
)
==
0
author
=
await
querier
.
get_author
(
author_id
=
book
.
author_id
)
assert
author
.
name
==
"Unknown Master"
assert
len
(
expected_titles
)
==
0
books
=
querier
.
books_by_tags
(
dollar_1
=
[
"cool"
,
"other"
,
"someother"
])
expected_titles
=
{
"changed second title"
,
"the third book"
,
"never ever gonna finish, a quatrain"
}
async
for
book
in
books
:
expected_titles
.
remove
(
book
.
title
)
assert
len
(
expected_titles
)
==
0
b5
=
await
querier
.
get_book
(
book_id
=
b3
.
book_id
)
assert
b5
is
not
None
await
querier
.
delete_book
(
book_id
=
b5
.
book_id
)
b6
=
await
querier
.
get_book
(
book_id
=
b5
.
book_id
)
assert
b6
is
None
Back
|
FazBrowse Home
|
New Git URL