Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flask-covid19
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
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
Thomas Wöhlke
flask-covid19
Commits
4f7e64c7
Commit
4f7e64c7
authored
4 years ago
by
thomaswoehlke
Browse files
Options
Downloads
Patches
Plain Diff
working for 0.0.198 Release
parent
75c07143
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/database.py
+0
-43
0 additions, 43 deletions
src/database.py
tests/conftest.py
+5
-4
5 additions, 4 deletions
tests/conftest.py
with
5 additions
and
47 deletions
src/database.py
+
0
−
43
View file @
4f7e64c7
...
...
@@ -23,37 +23,15 @@ def create_app():
return
my_app
def
create_app_test
():
my_app
=
Flask
(
'
covid19test
'
)
CORS
(
my_app
)
Bootstrap
(
my_app
)
my_app
.
config
.
from_object
(
"
config
"
)
db_url_test
=
'
postgresql+psycopg2://{user}:{pw}@{url}/{db}
'
.
format
(
user
=
my_app
.
config
[
'
SQLALCHEMY_POSTGRES_USER
'
],
pw
=
my_app
.
config
[
'
SQLALCHEMY_POSTGRES_PW
'
],
url
=
my_app
.
config
[
'
SQLALCHEMY_POSTGRES_URL
'
],
db
=
my_app
.
config
[
'
SQLALCHEMY_POSTGRES_DB_TEST
'
])
my_app
.
config
[
'
SQLALCHEMY_DATABASE_URI
'
]
=
db_url_test
my_app
.
config
[
'
SQLALCHEMY_TRACK_MODIFICATIONS
'
]
=
False
# silence the deprecation warning
my_app
.
config
[
'
FLASK_ADMIN_SWATCH
'
]
=
'
superhero
'
return
my_app
def
create_db
(
my_app
):
my_db
=
SQLAlchemy
(
my_app
)
my_db
.
create_all
()
return
my_db
def
create_db_test
(
my_app
):
my_db
=
SQLAlchemy
(
my_app
)
return
my_db
def
create_celery
(
my_app
):
celery
=
Celery
(
my_app
.
import_name
,
#namespace="covid19",
backend
=
my_app
.
config
[
'
MY_CELERY_RESULT_BACKEND
'
],
broker
=
my_app
.
config
[
'
CELERY_BROKER_URL
'
],
worker_send_task_events
=
my_app
.
config
[
'
CELERY_CONF_WORKER_SEND_TASK_EVENTS
'
],
...
...
@@ -71,27 +49,6 @@ def create_celery(my_app):
return
celery
def
create_celery_test
(
my_app
):
celery
=
Celery
(
my_app
.
import_name
,
#namespace="covid19",
backend
=
my_app
.
config
[
'
TEST_MY_CELERY_RESULT_BACKEND
'
],
broker
=
my_app
.
config
[
'
TEST_CELERY_BROKER_URL
'
],
worker_send_task_events
=
my_app
.
config
[
'
CELERY_CONF_WORKER_SEND_TASK_EVENTS
'
],
task_send_sent_event
=
my_app
.
config
[
'
CELERY_CONF_TASK_SEND_SENT_EVENT
'
],
broker_transport_options
=
{
'
visibility_timeout
'
:
18000
,
'
max_retries
'
:
5
}
)
celery
.
conf
.
update
(
my_app
.
config
)
class
ContextTask
(
celery
.
Task
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
with
my_app
.
app_context
():
return
self
.
run
(
*
args
,
**
kwargs
)
celery
.
Task
=
ContextTask
return
celery
def
create_admin
(
my_app
):
my_admin
=
Admin
(
my_app
,
...
...
This diff is collapsed.
Click to expand it.
tests/conftest.py
+
5
−
4
View file @
4f7e64c7
import
os
import
tempfile
import
pytest
from
database
import
create_app
_test
,
create_
db
from
database
import
create_app
,
create_db
,
create_
admin
@pytest.fixture
def
app
():
app
=
create_app
_test
()
app
=
create_app
()
return
app
@pytest.fixture
def
client
():
app
=
create_app
_test
()
app
=
create_app
()
db_fd
,
app
.
config
[
'
DATABASE
'
]
=
tempfile
.
mkstemp
()
app
.
config
[
'
TESTING
'
]
=
True
with
app
.
test_client
()
as
client
:
with
app
.
app_context
():
create_db
(
app
)
db
=
create_db
(
app
)
admin
=
create_admin
(
app
)
yield
client
os
.
close
(
db_fd
)
...
...
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