Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZKAPAuthorizer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Administrator
ZKAPAuthorizer
Commits
37d652f5
Commit
37d652f5
authored
3 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
compared structured dumps instead of text dumps
parent
e8f36eea
No related branches found
No related tags found
1 merge request
!312
Compare structured SQL dumps
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/_zkapauthorizer/tests/test_recover.py
+39
-3
39 additions, 3 deletions
src/_zkapauthorizer/tests/test_recover.py
with
39 additions
and
3 deletions
src/_zkapauthorizer/tests/test_recover.py
+
39
−
3
View file @
37d652f5
...
@@ -48,7 +48,7 @@ from ..tahoe import MemoryGrid, Tahoe, link, make_directory, upload
...
@@ -48,7 +48,7 @@ from ..tahoe import MemoryGrid, Tahoe, link, make_directory, upload
from
.fixtures
import
Treq
from
.fixtures
import
Treq
from
.matchers
import
matches_capability
from
.matchers
import
matches_capability
from
.resources
import
client_manager
from
.resources
import
client_manager
from
.sql
import
Table
,
create_table
from
.sql
import
Table
,
create_table
,
escape
from
.strategies
import
(
from
.strategies
import
(
api_auth_tokens
,
api_auth_tokens
,
deletes
,
deletes
,
...
@@ -73,9 +73,45 @@ def equals_db(reference: Connection):
...
@@ -73,9 +73,45 @@ def equals_db(reference: Connection):
:return: A matcher for a SQLite3 connection to a database with the same
:return: A matcher for a SQLite3 connection to a database with the same
state as the reference connection
'
s database.
state as the reference connection
'
s database.
"""
"""
def
structured_dump
(
db
):
tables
=
list
(
structured_dump_tables
(
db
))
for
(
name
,
sql
)
in
tables
:
yield
sql
yield
from
structured_dump_table
(
db
,
name
)
def
structured_dump_tables
(
db
):
curs
=
db
.
cursor
()
curs
.
execute
(
"""
SELECT [name], [sql]
FROM [sqlite_master]
WHERE [sql] NOT NULL and [type] ==
'
table
'
ORDER BY [name]
"""
)
yield
from
iter
(
curs
)
def
structured_dump_table
(
db
,
table_name
):
curs
=
db
.
cursor
()
curs
.
execute
(
f
"
PRAGMA table_info(
{
escape
(
table_name
)
}
)
"
)
columns
=
list
(
(
name
,
type_
)
for
(
cid
,
name
,
type_
,
notnull
,
dftl_value
,
pk
)
in
list
(
curs
)
)
column_names
=
"
,
"
.
join
(
escape
(
name
)
for
(
name
,
type_
)
in
columns
)
curs
.
execute
(
f
"""
SELECT
{
column_names
}
FROM
{
escape
(
table_name
)
}
"""
)
for
rows
in
iter
(
lambda
:
curs
.
fetchmany
(
1024
),
[]):
yield
from
rows
return
AfterPreprocessing
(
return
AfterPreprocessing
(
lambda
actual
:
list
(
actual
.
iterdump
(
)),
lambda
actual
:
list
(
structured_dump
(
actual
)),
Equals
(
list
(
reference
.
iterdump
(
))),
Equals
(
list
(
structured_dump
(
reference
))),
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment