-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
49 lines (36 loc) · 1.46 KB
/
tests.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
47
48
49
import pytest
import os
import clean_data as cd
import search as sh
if __name__ == '__main__':
os.system("pytest -v ./tests.py")
### if this test fails then there is a huge problem ###
def test_list_length():
# make sure both lists are the same length
assert len(cd.en_data) == len(cd.fr_data), "Data lists not the same length"
def test_clean_hello():
# make sure the string cleaning work properly
assert sh.clean_input_str(" hello )") == "hello", "Incorrect Output"
def test_clean_hi():
# make sure the string cleaning work properly
assert sh.clean_input_str(" * ._ hi )") == "hi", "Incorrect Output"
# test some strings and see results
def test_hello():
text = " hello "
result = sh.get_result(text, True)
assert result == ['salut', 'bonjour', 're-bonjour'], "Incorrect Results"
def test_goodbye():
text = "goodbye"
result = sh.get_result(text, True)
assert result == ['adieu', 'à la revoyure',
'dis au revoir'], "Incorrect Results"
def test_gibberish():
text = "qwertyuiopasdfghjklzxcvbnm"
result = sh.get_result(text, True)
assert result == [], "Incorrect Results"
### NOTE: Not testing with empty string because callsite will only allow the get_all function to be called with a non empty string.
# if I had to test for empty string, this is what I would do:
# def test_empty():
# text = ""
# result = sh.get_result(text, False)
# assert result == [], "Incorrect Results"