Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Vincent Wehrwein
website
Commits
9259d4e5
Unverified
Commit
9259d4e5
authored
6 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
added tests
parent
aa180d51
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
tests/flaskunittest.py
+23
-0
23 additions, 0 deletions
tests/flaskunittest.py
tests/test_jobmanagement.py
+2
-13
2 additions, 13 deletions
tests/test_jobmanagement.py
tests/test_misc.py
+0
-0
0 additions, 0 deletions
tests/test_misc.py
tests/test_sorter.py
+65
-0
65 additions, 0 deletions
tests/test_sorter.py
with
90 additions
and
13 deletions
tests/flaskunittest.py
0 → 100644
+
23
−
0
View file @
9259d4e5
import
unittest
import
server
import
flask
import
os
import
random
class
FlaskTestCase
(
unittest
.
TestCase
):
def
tearDown
(
self
):
pass
def
setUp
(
self
):
server
.
app
.
testing
=
True
self
.
requestContext
=
server
.
app
.
test_request_context
()
self
.
client
=
server
.
app
.
test_client
()
self
.
app
=
server
.
app
def
videoagLogin
(
self
):
self
.
sess_csrf_token
=
os
.
urandom
(
32
)
self
.
sess_dbid
=
random
.
randint
(
0
,
100
)
self
.
sess_username
=
'
videoag
'
with
self
.
client
.
session_transaction
()
as
sess
:
sess
[
'
user
'
]
=
{
'
name
'
:
self
.
sess_username
,
'
_csrf_token
'
:
self
.
csrf_token
,
'
dbid
'
:
self
.
sess_dbid
}
sess
[
'
_csrf_token
'
]
=
self
.
sess_csrf_token
This diff is collapsed.
Click to expand it.
tests/test_jobmanagement.py
+
2
−
13
View file @
9259d4e5
import
unittest
from
flaskunittest
import
FlaskTestCase
import
server
import
flask
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
import
jobmanagement
import
jobmanagement
from
server
import
query
from
server
import
query
class
JobmanagementTestCase
(
unittest
.
TestCase
):
class
JobmanagementTestCase
(
FlaskTestCase
):
def
tearDown
(
self
):
pass
def
setUp
(
self
):
server
.
app
.
testing
=
True
self
.
requestContext
=
server
.
app
.
test_request_context
()
self
.
client
=
server
.
app
.
test_client
()
self
.
app
=
server
.
app
def
getJobCount
(
self
,
state
=
None
):
def
getJobCount
(
self
,
state
=
None
):
if
not
state
:
if
not
state
:
data
=
query
(
"
SELECT count(id) AS count from jobs
"
)
data
=
query
(
"
SELECT count(id) AS count from jobs
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_
general
.py
→
tests/test_
misc
.py
+
0
−
0
View file @
9259d4e5
File moved
This diff is collapsed.
Click to expand it.
tests/test_sorter.py
0 → 100644
+
65
−
0
View file @
9259d4e5
from
flaskunittest
import
FlaskTestCase
import
sorter
from
datetime
import
datetime
,
date
,
time
class
SorterTestCase
(
FlaskTestCase
):
def
test_split_filename
(
self
):
testdata
=
[
{
'
filename
'
:
'
asdasd
'
,
'
chunks
'
:
[
'
asdasd
'
]},
{
'
filename
'
:
'
a-b-c-d
'
,
'
chunks
'
:
[
'
a
'
,
'
b
'
,
'
c
'
,
'
d
'
]},
{
'
filename
'
:
'
a_
'
,
'
chunks
'
:
[
'
a
'
,
''
]},
{
'
filename
'
:
'
a-
'
,
'
chunks
'
:
[
'
a
'
,
''
]},
{
'
filename
'
:
'
a
'
,
'
chunks
'
:
[
'
a
'
,
''
]},
{
'
filename
'
:
'
-ß
'
,
'
chunks
'
:
[
''
,
'
ß
'
]},
{
'
filename
'
:
'
b-a.mp4
'
,
'
chunks
'
:
[
'
b
'
,
'
a.mp4
'
]},
{
'
filename
'
:
''
,
'
chunks
'
:
[
''
]}
]
for
test
in
testdata
:
result
=
sorter
.
split_filename
(
test
[
'
filename
'
])
assert
result
==
test
[
'
chunks
'
],
'
result was {}, should be {}
'
.
format
(
result
,
test
)
def
extract_format_keyword_from_filename
(
self
):
testdata
=
[
{
'
chunks
'
:
[
''
,
''
],
'
format
'
:
''
},
{
'
chunks
'
:
[
'
asd
'
,
'
720p
'
],
'
format
'
:
'
720p
'
},
{
'
chunks
'
:
[
'
asd
'
,
'
720P
'
],
'
format
'
:
'
720p
'
},
{
'
chunks
'
:
[
'
asd
'
,
'
#\ää
'
],
'
format
'
:
'
#\ää
'
},
{
'
chunks
'
:
[
'
123
'
],
'
format
'
:
'
123
'
},
]
for
test
in
testdata
:
result
=
sorter
.
extract_format_keyword_from_filename
(
test
[
'
chunks
'
])
assert
result
==
test
[
'
format
'
],
'
result was {}, should be {}
'
.
format
(
result
,
test
)
def
test_filter_formats_by_filename
(
self
):
testdata
=
[
{
'
chunks
'
:
[
'
ääüp
'
,
'
ßääää
'
],
'
format
'
:
0
},
{
'
chunks
'
:
[
'
123üß
'
,
'
720P
'
],
'
format
'
:
5
},
{
'
chunks
'
:
[
'
testvideo
'
,
'
1080p
'
],
'
format
'
:
4
},
{
'
chunks
'
:
[
'
mp3
'
],
'
format
'
:
7
},
]
with
self
.
requestContext
:
for
test
in
testdata
:
result
=
sorter
.
filter_formats_by_filename
(
test
[
'
chunks
'
])
assert
result
==
test
[
'
formatid
'
],
'
result was {}, should be {}
'
.
format
(
result
,
test
)
def
test_parse_filename
(
self
):
testdata
=
[
{
'
filename
'
:
''
,
'
data
'
:
{
'
keywords
'
:
[
''
]}},
{
'
filename
'
:
'
18ss-mc-180413_720p.mp4
'
,
'
data
'
:
{
'
keywords
'
:
[
'
18ss
'
,
'
mc
'
,
'
720p
'
],
'
date
'
:
date
(
year
=
2018
,
month
=
4
,
day
=
13
)}},
{
'
filename
'
:
'
astaintern-astawiki-1080p.mp4
'
,
'
data
'
:
{
'
keywords
'
:
[
'
astaintern
'
,
'
astawiki
'
,
'
1080p
'
]}},
{
'
filename
'
:
'
15ss-zkk-extremale-codes-720p.mp4
'
,
'
data
'
:
{
'
keywords
'
:
[
'
15ss
'
,
'
zkk
'
,
'
extremale
'
,
'
codes
'
,
'
720p
'
]}},
# TODO: missing test data for time
]
for
test
in
testdata
:
result
=
sorter
.
parse_filename
(
sorter
.
split_filename
(
test
[
'
filename
'
]))
assert
result
==
test
[
'
data
'
],
'
result was {}, should be {}
'
.
format
(
result
,
test
[
'
data
'
])
def
test_filter_lectures_by_keywords
(
self
):
pass
def
test_filter_lectures_by_datetime
(
self
):
pass
def
test_filter_formats_by_filename
(
self
):
pass
def
test_sort_file
(
self
):
pass
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