-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_generate_sample_data.py
47 lines (31 loc) · 1.03 KB
/
test_generate_sample_data.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
import pytest
from main import generate_sample_data
def test_sample_data_length():
size = 10
max_list_length = 5
data = generate_sample_data(size, max_list_length)
assert len(data) <= size * max_list_length
assert len(data) >= size
def test_sample_data_key_length():
data = generate_sample_data(10, 5)
for key, _ in data:
assert len(key) == 3
def test_sample_data_value_type():
data = generate_sample_data(10, 5)
for _, value in data:
assert isinstance(value, int)
def test_zero_size():
with pytest.raises(ValueError):
generate_sample_data(0, 5)
def test_zero_max_list_length():
with pytest.raises(ValueError):
generate_sample_data(5, 0)
def test_large_values():
data = generate_sample_data(1000, 1000)
assert len(data) <= 1000 * 1000
def test_negative_values():
with pytest.raises(ValueError):
generate_sample_data(-1, -1)
def test_non_integer_values():
with pytest.raises(TypeError):
generate_sample_data("size", "max_list_length")