Skip to content

Commit 810be2b

Browse files
committed
Add LIST tests
1 parent 3a0c7fd commit 810be2b

File tree

2 files changed

+54
-19
lines changed

2 files changed

+54
-19
lines changed

tests/test_data_list_nodes.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import pytest
22
from src.basic_data_handling.data_list_nodes import (
33
DataListAppend,
4-
DataListCreate,
5-
DataListCreateFromBoolean,
6-
DataListCreateFromFloat,
7-
DataListCreateFromInt,
8-
DataListCreateFromString,
4+
#DataListCreate,
5+
#DataListCreateFromBoolean,
6+
#DataListCreateFromFloat,
7+
#DataListCreateFromInt,
8+
#DataListCreateFromString,
99
DataListExtend,
1010
DataListInsert,
1111
DataListRemove,
@@ -27,8 +27,8 @@
2727
DataListLast,
2828
DataListMin,
2929
DataListMax,
30-
DataListToList,
31-
DataListToSet,
30+
#DataListToList,
31+
#DataListToSet,
3232
)
3333

3434

tests/test_list_nodes.py

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
import pytest
22
from src.basic_data_handling.list_nodes import (
3+
ListAppend,
4+
ListContains,
5+
ListCount,
36
ListCreate,
47
ListCreateFromBoolean,
58
ListCreateFromFloat,
69
ListCreateFromInt,
710
ListCreateFromString,
8-
ListAppend,
911
ListExtend,
12+
ListFirst,
13+
ListGetItem,
14+
ListIndex,
1015
ListInsert,
11-
ListRemove,
16+
ListLast,
17+
ListLength,
18+
ListMax,
19+
ListMin,
1220
ListPop,
13-
ListIndex,
14-
ListCount,
15-
ListSort,
21+
ListPopRandom,
22+
ListRemove,
1623
ListReverse,
17-
ListLength,
18-
ListSlice,
19-
ListGetItem,
2024
ListSetItem,
21-
ListContains,
22-
ListMin,
23-
ListMax,
25+
ListSlice,
26+
ListSort,
2427
ListToDataList,
25-
ListToSet
28+
ListToSet,
2629
)
2730

2831

@@ -61,6 +64,38 @@ def test_list_pop():
6164
assert node.pop([], 0) == ([], None) # Empty list pop
6265

6366

67+
def test_list_pop_random():
68+
node = ListPopRandom()
69+
# Test with single item - must remove that item
70+
result, item = node.pop_random_element([42])
71+
assert result == [] and item == 42
72+
73+
# Test with multiple items - can't predict which one will be popped
74+
# but we can check the result list length and that the popped item was from the original list
75+
original_list = [1, 2, 3, 4]
76+
result, item = node.pop_random_element(original_list)
77+
assert len(result) == len(original_list) - 1
78+
assert item in original_list
79+
assert item not in result
80+
81+
# Test with empty list
82+
assert node.pop_random_element([]) == ([], None)
83+
84+
85+
def test_list_first():
86+
node = ListFirst()
87+
assert node.get_first_element([1, 2, 3]) == (1,)
88+
assert node.get_first_element(["a", "b", "c"]) == ("a",)
89+
assert node.get_first_element([]) == (None,) # Empty list
90+
91+
92+
def test_list_last():
93+
node = ListLast()
94+
assert node.get_last_element([1, 2, 3]) == (3,)
95+
assert node.get_last_element(["a", "b", "c"]) == ("c",)
96+
assert node.get_last_element([]) == (None,) # Empty list
97+
98+
6499
def test_list_index():
65100
node = ListIndex()
66101
assert node.index([1, 2, 3, 2], 2) == (1,)

0 commit comments

Comments
 (0)