Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
network
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
network
Commits
8c0c6802
Verified
Commit
8c0c6802
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Delete checks when instance is private
parent
80e74622
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
funkwhale_network/crawler.py
+5
-0
5 additions, 0 deletions
funkwhale_network/crawler.py
tests/test_crawler.py
+30
-2
30 additions, 2 deletions
tests/test_crawler.py
with
35 additions
and
2 deletions
funkwhale_network/crawler.py
+
5
−
0
View file @
8c0c6802
...
@@ -144,6 +144,11 @@ async def save_check(cursor, data):
...
@@ -144,6 +144,11 @@ async def save_check(cursor, data):
await
cursor
.
execute
(
sql
,
values
)
await
cursor
.
execute
(
sql
,
values
)
check
=
await
cursor
.
fetchone
()
check
=
await
cursor
.
fetchone
()
if
data
.
get
(
"
private
"
)
is
True
:
# let's clean previous checks
sql
=
"
DELETE FROM checks WHERE domain = %s
"
await
cursor
.
execute
(
sql
,
[
data
[
"
domain
"
]])
return
if
node_name
:
if
node_name
:
await
cursor
.
execute
(
await
cursor
.
execute
(
"
UPDATE domains SET node_name = %s WHERE name = %s
"
,
"
UPDATE domains SET node_name = %s WHERE name = %s
"
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_crawler.py
+
30
−
2
View file @
8c0c6802
...
@@ -177,7 +177,8 @@ async def test_clean_check_result():
...
@@ -177,7 +177,8 @@ async def test_clean_check_result():
assert
crawler
.
clean_check
(
check
,
data
)
==
expected
assert
crawler
.
clean_check
(
check
,
data
)
==
expected
async
def
test_save_check
(
populated_db
,
db_cursor
,
db_conn
):
async
def
test_save_check
(
populated_db
,
db_cursor
,
db_conn
,
factories
):
await
factories
[
"
Check
"
].
c
(
domain
=
"
test.domain
"
,
private
=
False
)
await
serializers
.
create_domain
(
db_conn
,
{
"
name
"
:
"
test.domain
"
})
await
serializers
.
create_domain
(
db_conn
,
{
"
name
"
:
"
test.domain
"
})
data
=
{
data
=
{
"
domain
"
:
"
test.domain
"
,
"
domain
"
:
"
test.domain
"
,
...
@@ -203,7 +204,7 @@ async def test_save_check(populated_db, db_cursor, db_conn):
...
@@ -203,7 +204,7 @@ async def test_save_check(populated_db, db_cursor, db_conn):
"
software_build
"
:
"
git.b575999e
"
,
"
software_build
"
:
"
git.b575999e
"
,
}
}
sql
=
"
SELECT * from checks
"
sql
=
"
SELECT * from checks
ORDER BY time DESC
"
result
=
await
crawler
.
save_check
(
db_conn
,
data
)
result
=
await
crawler
.
save_check
(
db_conn
,
data
)
await
db_cursor
.
execute
(
sql
)
await
db_cursor
.
execute
(
sql
)
...
@@ -216,3 +217,30 @@ async def test_save_check(populated_db, db_cursor, db_conn):
...
@@ -216,3 +217,30 @@ async def test_save_check(populated_db, db_cursor, db_conn):
domain
=
await
db_cursor
.
fetchone
()
domain
=
await
db_cursor
.
fetchone
()
assert
domain
[
"
node_name
"
]
==
"
Test Domain
"
assert
domain
[
"
node_name
"
]
==
"
Test Domain
"
async
def
test_private_domain_delete_past_checks
(
populated_db
,
db_cursor
,
db_conn
,
factories
):
await
factories
[
"
Check
"
].
c
(
domain
=
"
test.domain
"
,
private
=
False
)
data
=
{
"
domain
"
:
"
test.domain
"
,
"
node_name
"
:
"
Test Domain
"
,
"
up
"
:
True
,
"
open_registrations
"
:
False
,
"
federation_enabled
"
:
True
,
"
anonymous_can_listen
"
:
True
,
"
private
"
:
True
,
"
software_name
"
:
"
funkwhale
"
,
"
software_version_major
"
:
0
,
"
software_version_minor
"
:
18
,
"
software_version_patch
"
:
0
,
"
software_prerelease
"
:
"
dev
"
,
"
software_build
"
:
"
git.b575999e
"
,
}
sql
=
"
SELECT * from checks
"
assert
await
crawler
.
save_check
(
db_conn
,
data
)
is
None
await
db_cursor
.
execute
(
sql
)
result
=
await
db_cursor
.
fetchall
()
assert
result
==
[]
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