Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
SMASCH
scheduling-system
Commits
69a377e9
Commit
69a377e9
authored
4 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
MEDIA_ROOT should modified only when running tests
parent
dadb78a2
No related branches found
No related tags found
1 merge request
!302
Deb issues
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/tests/__init__.py
+14
-7
14 additions, 7 deletions
smash/web/tests/__init__.py
with
14 additions
and
7 deletions
smash/web/tests/__init__.py
+
14
−
7
View file @
69a377e9
import
logging
import
os
import
sys
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.test
import
Client
from
django.test
import
TestCase
from
web.models
import
Worker
from
web.decorators
import
PermissionDecorator
from
web.decorators
import
PermissionDecorator
from
web.models
import
Worker
from
.functions
import
create_worker
,
create_user
,
add_permissions_to_worker
settings
.
MEDIA_ROOT
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'
data
'
)
# if manage.py test was called, use test settings
if
'
test
'
in
sys
.
argv
:
try
:
settings
.
MEDIA_ROOT
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'
data
'
)
except
ImportError
:
pass
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -19,7 +26,7 @@ class LoggedInTestCase(TestCase):
self
.
password
=
'
abcd1234
'
#superuser
self
.
super_worker
=
create_worker
(
user
=
User
.
objects
.
create_superuser
(
username
=
'
super
'
,
password
=
self
.
password
,
email
=
'
a@mail.com
'
))
#admin
#admin
self
.
admin_worker
=
Worker
.
get_by_user
(
create_user
(
username
=
'
admin
'
,
password
=
self
.
password
))
add_permissions_to_worker
(
self
.
admin_worker
,
PermissionDecorator
.
codenames
)
#staff
...
...
@@ -34,15 +41,15 @@ class LoggedInTestCase(TestCase):
def
login_as_staff
(
self
):
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
'
staff
'
,
password
=
self
.
password
)
self
.
client
.
login
(
username
=
'
staff
'
,
password
=
self
.
password
)
def
login_as_admin
(
self
):
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
'
admin
'
,
password
=
self
.
password
)
self
.
client
.
login
(
username
=
'
admin
'
,
password
=
self
.
password
)
def
login_as_super
(
self
):
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
'
super
'
,
password
=
self
.
password
)
self
.
client
.
login
(
username
=
'
super
'
,
password
=
self
.
password
)
class
LoggedInWithWorkerTestCase
(
LoggedInTestCase
):
...
...
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