Unverified Commit 9259d4e5 authored by Andreas Valder's avatar Andreas Valder
Browse files

added tests

parent aa180d51
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
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")
......
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment