FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlc-gen-python/examples/src/tests/test_authors.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_authors.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (40 loc) · 1.8 KB
Breadcrumbs
sqlc-gen-python
/
examples
/
src
/
tests
/
test_authors.py
Copy path
File metadata and controls
56 lines (40 loc) · 1.8 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
import
os
import
pytest
import
sqlalchemy
.
ext
.
asyncio
from
authors
import
query
from
dbtest
.
migrations
import
apply_migrations
,
apply_migrations_async
def
test_authors
(
db
:
sqlalchemy
.
engine
.
Connection
):
apply_migrations
(
db
, [
os
.
path
.
dirname
(
__file__
)
+
"/../authors/schema.sql"
])
querier
=
query
.
Querier
(
db
)
authors
=
list
(
querier
.
list_authors
())
assert
authors
==
[]
author_name
=
"Brian Kernighan"
author_bio
=
"Co-author of The C Programming Language and The Go Programming Language"
new_author
=
querier
.
create_author
(
name
=
author_name
,
bio
=
author_bio
)
assert
new_author
.
id
>
0
assert
new_author
.
name
==
author_name
assert
new_author
.
bio
==
author_bio
db_author
=
querier
.
get_author
(
id
=
new_author
.
id
)
assert
db_author
==
new_author
author_list
=
list
(
querier
.
list_authors
())
assert
len
(
author_list
)
==
1
assert
author_list
[
0
]
==
new_author
@
pytest
.
mark
.
asyncio
async
def
test_authors_async
(
async_db
:
sqlalchemy
.
ext
.
asyncio
.
AsyncConnection
):
await
apply_migrations_async
(
async_db
, [
os
.
path
.
dirname
(
__file__
)
+
"/../authors/schema.sql"
])
querier
=
query
.
AsyncQuerier
(
async_db
)
async
for
_
in
querier
.
list_authors
():
assert
False
,
"No authors should exist"
author_name
=
"Brian Kernighan"
author_bio
=
"Co-author of The C Programming Language and The Go Programming Language"
new_author
=
await
querier
.
create_author
(
name
=
author_name
,
bio
=
author_bio
)
assert
new_author
.
id
>
0
assert
new_author
.
name
==
author_name
assert
new_author
.
bio
==
author_bio
db_author
=
await
querier
.
get_author
(
id
=
new_author
.
id
)
assert
db_author
==
new_author
author_list
=
[]
async
for
author
in
querier
.
list_authors
():
author_list
.
append
(
author
)
assert
len
(
author_list
)
==
1
assert
author_list
[
0
]
==
new_author
Back
|
FazBrowse Home
|
New Git URL