Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
beat
beat.web
Commits
4296f03e
Commit
4296f03e
authored
8 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[team] Add test for undeletable team
parent
2fa520a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!206
Issue 406
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/team/tests.py
+36
-0
36 additions, 0 deletions
beat/web/team/tests.py
with
36 additions
and
0 deletions
beat/web/team/tests.py
+
36
−
0
View file @
4296f03e
...
@@ -31,11 +31,15 @@ from rest_framework import status
...
@@ -31,11 +31,15 @@ from rest_framework import status
from
rest_framework.test
import
APITestCase
from
rest_framework.test
import
APITestCase
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.conf
import
settings
import
os
import
shutil
import
simplejson
as
json
import
simplejson
as
json
from
..common.testutils
import
tearDownModule
from
..common.testutils
import
tearDownModule
from
.models
import
Team
from
.models
import
Team
from
..dataformats.models
import
DataFormat
from
.serializers
import
SimpleTeamSerializer
from
.serializers
import
SimpleTeamSerializer
...
@@ -57,6 +61,19 @@ class TeamTestCase(APITestCase):
...
@@ -57,6 +61,19 @@ class TeamTestCase(APITestCase):
self
.
invalid_username
=
'
janedoe
'
self
.
invalid_username
=
'
janedoe
'
# object to test sharing/deletion
if
os
.
path
.
exists
(
settings
.
DATAFORMATS_ROOT
):
shutil
.
rmtree
(
settings
.
DATAFORMATS_ROOT
)
(
dataformat
,
errors
)
=
DataFormat
.
objects
.
create_dataformat
(
author
=
self
.
johndoe
,
name
=
'
data_format_shared_with_private_team
'
,
)
assert
dataformat
,
errors
dataformat
.
share
(
teams
=
[
self
.
teamdoe_private
])
self
.
dataformat
=
dataformat
#----------------------------------------------------------
#----------------------------------------------------------
...
@@ -377,14 +394,31 @@ class TeamDeletionTestCase(TeamTestCase):
...
@@ -377,14 +394,31 @@ class TeamDeletionTestCase(TeamTestCase):
options
[
'
owner_name
'
]
=
self
.
johndoe
.
username
options
[
'
owner_name
'
]
=
self
.
johndoe
.
username
url
=
self
.
get_url
(
options
)
url
=
self
.
get_url
(
options
)
self
.
assertEqual
(
self
.
teamdoe
.
total_shares
(),
0
)
response
=
self
.
client
.
delete
(
url
,
format
=
'
json
'
)
response
=
self
.
client
.
delete
(
url
,
format
=
'
json
'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_204_NO_CONTENT
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_204_NO_CONTENT
)
def
test_logged_in_user_own_team_shared
(
self
):
self
.
client
.
login
(
username
=
self
.
johndoe
.
username
,
password
=
self
.
password
)
options
=
self
.
options
options
[
'
owner_name
'
]
=
self
.
johndoe
.
username
options
[
'
team_name
'
]
=
'
teamdoe_private
'
url
=
self
.
get_url
(
options
)
self
.
assertEqual
(
self
.
teamdoe_private
.
total_shares
(),
1
)
response
=
self
.
client
.
delete
(
url
,
format
=
'
json
'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_logged_in_user_team_from_other
(
self
):
def
test_logged_in_user_team_from_other
(
self
):
self
.
client
.
login
(
username
=
self
.
jackdoe
,
password
=
self
.
password
)
self
.
client
.
login
(
username
=
self
.
jackdoe
,
password
=
self
.
password
)
url
=
self
.
get_url
(
self
.
options
)
url
=
self
.
get_url
(
self
.
options
)
self
.
assertEqual
(
self
.
teamdoe
.
total_shares
(),
0
)
response
=
self
.
client
.
delete
(
url
,
format
=
'
json
'
)
response
=
self
.
client
.
delete
(
url
,
format
=
'
json
'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
...
@@ -396,6 +430,8 @@ class TeamDeletionTestCase(TeamTestCase):
...
@@ -396,6 +430,8 @@ class TeamDeletionTestCase(TeamTestCase):
options
[
'
owner_name
'
]
=
self
.
invalid_username
options
[
'
owner_name
'
]
=
self
.
invalid_username
url
=
self
.
get_url
(
options
)
url
=
self
.
get_url
(
options
)
self
.
assertEqual
(
self
.
teamdoe
.
total_shares
(),
0
)
response
=
self
.
client
.
delete
(
url
,
format
=
'
json
'
)
response
=
self
.
client
.
delete
(
url
,
format
=
'
json
'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_404_NOT_FOUND
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_404_NOT_FOUND
)
...
...
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