Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-lister
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine R. Dumont
swh-lister
Commits
d2512012
Verified
Commit
d2512012
authored
5 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
debian.models: Migrate tests from storage to debian lister model
Related bb5d405
parent
b2e5ce32
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mypy.ini
+3
-0
3 additions, 0 deletions
mypy.ini
swh/lister/debian/tests/conftest.py
+31
-1
31 additions, 1 deletion
swh/lister/debian/tests/conftest.py
swh/lister/debian/tests/test_models.py
+41
-0
41 additions, 0 deletions
swh/lister/debian/tests/test_models.py
with
75 additions
and
1 deletion
mypy.ini
+
3
−
0
View file @
d2512012
...
...
@@ -26,6 +26,9 @@ ignore_missing_imports = True
[mypy-pytest.*]
ignore_missing_imports
=
True
[mypy-pytest_postgresql.*]
ignore_missing_imports
=
True
[mypy-requests_mock.*]
ignore_missing_imports
=
True
...
...
This diff is collapsed.
Click to expand it.
swh/lister/debian/tests/conftest.py
+
31
−
1
View file @
d2512012
...
...
@@ -5,8 +5,12 @@
import
pytest
from
swh.lister.core.tests.conftest
import
*
# noqa
from
pytest_postgresql.janitor
import
DatabaseJanitor
from
sqlalchemy
import
create_engine
from
sqlalchemy.orm
import
sessionmaker
from
swh.lister.core.tests.conftest
import
*
# noqa
from
swh.lister.core.models
import
SQLBase
from
swh.lister.debian
import
debian_init
...
...
@@ -28,3 +32,29 @@ def lister_debian(swh_listers):
})
return
lister
@pytest.fixture
def
sqlalchemy_engine
(
postgresql_proc
):
pg_host
=
postgresql_proc
.
host
pg_port
=
postgresql_proc
.
port
pg_user
=
postgresql_proc
.
user
pg_db
=
'
sqlalchemy-tests
'
url
=
f
'
postgresql://
{
pg_user
}
@
{
pg_host
}
:
{
pg_port
}
/
{
pg_db
}
'
with
DatabaseJanitor
(
pg_user
,
pg_host
,
pg_port
,
pg_db
,
postgresql_proc
.
version
):
engine
=
create_engine
(
url
)
yield
engine
engine
.
dispose
()
@pytest.fixture
def
session
(
sqlalchemy_engine
):
SQLBase
.
metadata
.
create_all
(
sqlalchemy_engine
)
Session
=
sessionmaker
(
bind
=
sqlalchemy_engine
)
session
=
Session
()
yield
session
session
.
close
()
This diff is collapsed.
Click to expand it.
swh/lister/debian/tests/test_models.py
0 → 100644
+
41
−
0
View file @
d2512012
# Copyright (C) 2019 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import
pytest
from
swh.lister.debian.models
import
Distribution
,
Area
def
test_area_index_uris_deb
(
session
):
d
=
Distribution
(
name
=
'
Debian
'
,
type
=
'
deb
'
,
mirror_uri
=
'
http://deb.debian.org/debian
'
)
a
=
Area
(
distribution
=
d
,
name
=
'
unstable/main
'
,
active
=
True
,
)
session
.
add_all
([
d
,
a
])
session
.
commit
()
uris
=
list
(
a
.
index_uris
())
assert
uris
def
test_area_index_uris_rpm
(
session
):
d
=
Distribution
(
name
=
'
CentOS
'
,
type
=
'
rpm
'
,
mirror_uri
=
'
http://centos.mirrors.proxad.net/
'
)
a
=
Area
(
distribution
=
d
,
name
=
'
8
'
,
active
=
True
,
)
session
.
add_all
([
d
,
a
])
session
.
commit
()
with
pytest
.
raises
(
NotImplementedError
):
list
(
a
.
index_uris
())
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