Skip to content
This repository was archived by the owner on Sep 7, 2024. It is now read-only.

Commit a61e450

Browse files
committed
refactor: python normal test
1 parent f34c6ac commit a61e450

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ cmd/config.yaml
3131
/client
3232
log.ttrace
3333
build/
34+
35+
# python cache files
36+
test/__pycache__

test/normal_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_ping_ok():
3939
def test_new_set_ok():
4040
#* Creating some random sets.
4141
for i in range(10):
42-
set_names.append(utils.get_random_string(i+2))
42+
set_names.append(utils.get_random_string_name(i+2))
4343

4444
query = f"SET {set_names[i]}"
4545
response = utils.make_query(query, sock)
@@ -52,7 +52,7 @@ def test_new_sub_set_ok():
5252
#* Creating some random sub sets.
5353
for s in set_names:
5454
for i in range(7):
55-
sub_set_names.append(utils.get_random_string(i+2))
55+
sub_set_names.append(utils.get_random_string_name(i+2))
5656

5757
query = f"SSET {s} {sub_set_names[i]}"
5858
response = utils.make_query(query, sock)
@@ -67,7 +67,7 @@ def test_push_element_ok():
6767
for s in set_names:
6868
for i in range(7):
6969
for _ in range(1_000):
70-
element_value = utils.get_random_string(i+8)
70+
element_value = utils.get_random_string_name(i+8)
7171
elements_value.append(element_value)
7272

7373
query = f"PUSH {s} {sub_set_names[i]} {element_value} {int(time.mktime(time.gmtime()))}"

test/utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import random
22
import string
3+
import socket
34

4-
def get_random_string(length):
5+
def get_random_string_name(length: int) -> str:
56
return ''.join(random.choice(string.ascii_lowercase) for i in range(length))
67

7-
def make_query(query, sock):
8+
def make_query(query: str, sock: socket.socket) -> str:
89
sock.sendall(query.encode())
910
return sock.recv(1024).decode()

0 commit comments

Comments
 (0)