Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grady
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
Jan Maximilian Michal
grady
Merge requests
!192
Resolve "Provide import functionality via frontend for reviewers"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Provide import functionality via frontend for reviewers"
189-provide-import-functionality-via-frontend-for-reviewers
into
master
Overview
0
Commits
4
Pipelines
19
Changes
5
Merged
Dominik Seeger
requested to merge
189-provide-import-functionality-via-frontend-for-reviewers
into
master
5 years ago
Overview
0
Commits
4
Pipelines
19
Changes
5
Expand
Closes
#189 (closed)
Edited
5 years ago
by
robinwilliam.hundt
0
0
Merge request reports
Viewing commit
f3d982d4
Show latest version
5 files
+
117
−
3
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
f3d982d4
added import endpoint
· f3d982d4
Dominik Seeger
authored
5 years ago
core/tests/test_import_views.py
0 → 100644
+
80
−
0
Options
from
rest_framework
import
status
from
rest_framework.test
import
APIClient
,
APITestCase
from
core.models
import
UserAccount
,
SubmissionType
from
util.factories
import
GradyUserFactory
test_data
=
{
"
meta
"
:
{
"
version
"
:
"
3.0.0
"
},
"
module
"
:
{
"
module_reference
"
:
"
test
"
,
"
pass_only
"
:
True
,
"
pass_score
"
:
1
,
"
total_score
"
:
99
},
"
students
"
:
[
{
"
fullname
"
:
"
test
"
,
"
identifier
"
:
"
test-test
"
,
"
submissions
"
:
[
{
"
code
"
:
"
some messy, perhaps incorrect stuff
"
,
"
tests
"
:
{},
"
type
"
:
"
[a0] coding stuff
"
},
{
"
code
"
:
"
i don
'
t know man
"
,
"
tests
"
:
{},
"
type
"
:
"
[a1] improvise
"
}
],
}
],
"
submission_types
"
:
[
{
"
description
"
:
"
code some 1337 stuff
"
,
"
full_score
"
:
99
,
"
name
"
:
"
[a0] coding stuff
"
,
"
programming_language
"
:
"
c
"
,
"
solution
"
:
"
how dare u
"
},
{
"
description
"
:
"
now this one
'
s hard
"
,
"
full_score
"
:
1
,
"
name
"
:
"
[a1] improvise
"
,
"
programming_language
"
:
"
haskell
"
,
"
solution
"
:
"
nope
"
},
]
}
class
ImportViewTest
(
APITestCase
):
factory
=
GradyUserFactory
()
def
setUp
(
self
):
self
.
url
=
'
/api/import/
'
self
.
client
=
APIClient
()
self
.
client
.
force_login
(
user
=
self
.
factory
.
make_reviewer
())
def
test_can_not_submit_nothing
(
self
):
res
=
self
.
client
.
post
(
self
.
url
)
self
.
assertEqual
(
status
.
HTTP_400_BAD_REQUEST
,
res
.
status_code
)
def
test_will_fail_on_wrong_importer_version
(
self
):
data
=
{
"
meta
"
:
{
"
version
"
:
"
0.0.0
"
}}
res
=
self
.
client
.
post
(
self
.
url
,
data
)
self
.
assertEqual
(
status
.
HTTP_409_CONFLICT
,
res
.
status_code
)
def
test_data_is_imported_correctly
(
self
):
res
=
self
.
client
.
post
(
self
.
url
,
test_data
)
sub_types
=
SubmissionType
.
objects
.
all
()
students
=
UserAccount
.
objects
.
all
().
filter
(
role
=
'
Student
'
)
self
.
assertEqual
(
2
,
len
(
sub_types
))
self
.
assertEqual
(
1
,
len
(
students
))
self
.
assertEqual
(
status
.
HTTP_201_CREATED
,
res
.
status_code
)
Loading