-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
46 lines (37 loc) · 1.51 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import unittest
import api
import defs
from flask import Flask, abort, render_template, request, send_file
class MyTestCase(unittest.TestCase):
def setUp(self):
self.app = api.app.test_client()
self.app.testing = True
def test_home(self):
res = self.app.get('/statsapi')
self.assertEqual(res.status_code, 200)
def test_results_for_directory_no_word_or_ext(self):
sent = {'path':'testfiles/', 'extensions':'', 'word':''}
res = self.app.post('/result', data=sent)
self.assertEqual(res.status_code, 200)
def test_results_for_directory_word_no_ext(self):
sent = {'path':'testfiles/', 'extensions':'', 'word':'the'}
res = self.app.post('/result', data=sent)
self.assertEqual(res.status_code, 200)
def test_results_for_directory_no_word_ext(self):
sent = {'path':'testfiles/', 'extensions':'.txt', 'word':''}
res = self.app.post('/result', data=sent)
self.assertEqual(res.status_code, 200)
def test_results_for_directory_word_ext(self):
sent = {'path':'testfiles/', 'extensions':'', 'word':''}
res = self.app.post('/result', data=sent)
self.assertEqual(res.status_code, 200)
def test_results_for_file(self):
sent = {'path':'testfiles/second.txt', 'extensions':'', 'word':''}
res = self.app.post('/result', data=sent)
self.assertEqual(res.status_code, 200)
def test_results_for_file_word(self):
sent = {'path':'testfiles/second.txt', 'extensions':'', 'word':'день'}
res = self.app.post('/result', data=sent)
self.assertEqual(res.status_code, 200)
if __name__ == '__main__':
unittest.main()