-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_redisWithPython.py
44 lines (29 loc) · 1.36 KB
/
test_redisWithPython.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
import hashes
import redis
import os
REDIS_URL = 'http://localhost:6379'
r = redis.from_url(REDIS_URL, charset="utf-8", decode_responses=True)
def test_get_all_keys():
assert len(hashes.get_all_keys()) == len(r.keys()), "C'est en fait " + str(len(hashes.get_all_keys()))
def test_get_all_tweets():
assert len(hashes.get_all_tweets()) == len(r.zrange('messages', 0, -1))
def test_get_tweet():
assert hashes.get_tweet('mid:2') == r.hgetall('mid:2')
def test_name_check_is_ok():
assert hashes.name_check('@vanessa') == True, hashes.name_check('@vanessa')
def test_name_check_with_spec_charac_is_ok():
assert hashes.name_check('@anna-livia') == True
def test_name_check_with_accent_charac_is_ok():
assert hashes.name_check('@Étienne') == True
def test_name_check_WO_arobase_is_NOK():
assert hashes.name_check('vanessa') == False
def test_name_check_with_blank_space_is_NOK():
assert hashes.name_check("@vanessa is here") == False
def test_name_check_with_weird_charac_is_NOK():
assert hashes.name_check("@vanessa%is/here") == False
def test_name_check_with_no_charac_is_NOK():
assert hashes.name_check("") == False
def test_check_user_password_al_admin_OK():
assert hashes.check_user_password("@admin", "admin") == True
def test_check_user_password_al_admin_NOK():
assert hashes.check_user_password("@admin", "pas_admin") == False