Fix tests
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import pytest
|
||||
from src.basic_data_handling.casting_nodes import (CastToString, CastToInt, CastToFloat, CastToBoolean,
|
||||
CastToList, CastDataListToList, CastToSet, CastDataListToSet,
|
||||
CastToDict)
|
||||
CastToList, CastToSet, CastToDict)
|
||||
|
||||
|
||||
def test_cast_to_string():
|
||||
@@ -49,13 +48,6 @@ def test_cast_to_list():
|
||||
assert node.convert_to_list(None) == ([None],)
|
||||
|
||||
|
||||
def test_cast_data_list_to_list():
|
||||
node = CastDataListToList()
|
||||
assert node.convert(list=[1, 2, 3]) == ([1, 2, 3],)
|
||||
assert node.convert(list=[]) == ([],)
|
||||
assert node.convert(list=["a", "b", "c"]) == (["a", "b", "c"],)
|
||||
|
||||
|
||||
def test_cast_to_set():
|
||||
node = CastToSet()
|
||||
assert node.convert_to_set(123) == ({123},)
|
||||
@@ -64,13 +56,6 @@ def test_cast_to_set():
|
||||
assert node.convert_to_set(None) == ({None},)
|
||||
|
||||
|
||||
def test_cast_data_list_to_set():
|
||||
node = CastDataListToSet()
|
||||
assert node.convert(list=[1, 2, 3, 3]) == ({1, 2, 3},)
|
||||
assert node.convert(list=["a", "b", "b"]) == ({"a", "b"},)
|
||||
assert node.convert(list=[]) == (set(),)
|
||||
|
||||
|
||||
def test_cast_to_dict():
|
||||
node = CastToDict()
|
||||
assert node.convert_to_dict({"key": "value"}) == ({"key": "value"},)
|
||||
|
||||
@@ -5,12 +5,10 @@ from src.basic_data_handling.data_list_nodes import (
|
||||
DataListInsert,
|
||||
DataListRemove,
|
||||
DataListPop,
|
||||
DataListClear,
|
||||
DataListIndex,
|
||||
DataListCount,
|
||||
DataListSort,
|
||||
DataListReverse,
|
||||
DataListCopy,
|
||||
DataListLength,
|
||||
DataListSlice,
|
||||
DataListGetItem,
|
||||
@@ -59,12 +57,6 @@ def test_pop():
|
||||
assert node.pop(list=[], index=[0]) == ([], None) # Pop from empty list
|
||||
|
||||
|
||||
def test_clear():
|
||||
node = DataListClear()
|
||||
assert node.clear(list=[1, 2, 3]) == ([],)
|
||||
assert node.clear(list=[]) == ([],)
|
||||
|
||||
|
||||
def test_index():
|
||||
node = DataListIndex()
|
||||
assert node.list_index(list=["a", "b", "c"], value=["b"]) == (1,)
|
||||
@@ -92,12 +84,6 @@ def test_reverse():
|
||||
assert node.reverse(list=[]) == ([],)
|
||||
|
||||
|
||||
def test_copy():
|
||||
node = DataListCopy()
|
||||
assert node.copy(list=[1, 2, 3]) == ([1, 2, 3],)
|
||||
assert node.copy(list=[]) == ([],)
|
||||
|
||||
|
||||
def test_length():
|
||||
node = DataListLength()
|
||||
assert node.length(list=[1, 2, 3]) == (3,)
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
#import pytest
|
||||
from src.basic_data_handling.dict_nodes import (
|
||||
DictCreate,
|
||||
DictCreateFromItems,
|
||||
DictGet,
|
||||
DictSet,
|
||||
DictKeys,
|
||||
DictValues,
|
||||
DictItems,
|
||||
DictContainsKey,
|
||||
DictClear,
|
||||
DictCopy,
|
||||
DictFromKeys,
|
||||
DictPop,
|
||||
DictPopItem,
|
||||
@@ -25,7 +22,6 @@ from src.basic_data_handling.dict_nodes import (
|
||||
DictInvert,
|
||||
DictCreateFromLists,
|
||||
DictCompare,
|
||||
AnyToDict,
|
||||
)
|
||||
|
||||
def test_dict_create():
|
||||
@@ -33,12 +29,6 @@ def test_dict_create():
|
||||
assert node.create() == ({},) # Creates an empty dictionary
|
||||
|
||||
|
||||
def test_dict_create_from_items():
|
||||
node = DictCreateFromItems()
|
||||
items = [("key1", "value1"), ("key2", "value2")]
|
||||
assert node.create_from_items(items) == ({"key1": "value1", "key2": "value2"},)
|
||||
|
||||
|
||||
def test_dict_get():
|
||||
node = DictGet()
|
||||
my_dict = {"key1": "value1", "key2": "value2"}
|
||||
@@ -77,18 +67,6 @@ def test_dict_contains_key():
|
||||
assert node.contains_key(my_dict, "key2") == (False,)
|
||||
|
||||
|
||||
def test_dict_clear():
|
||||
node = DictClear()
|
||||
my_dict = {"key1": "value1"}
|
||||
assert node.clear(my_dict) == ({},)
|
||||
|
||||
|
||||
def test_dict_copy():
|
||||
node = DictCopy()
|
||||
my_dict = {"key1": "value1"}
|
||||
assert node.copy(my_dict) == ({"key1": "value1"},)
|
||||
|
||||
|
||||
def test_dict_from_keys():
|
||||
node = DictFromKeys()
|
||||
keys = ["key1", "key2"]
|
||||
@@ -185,9 +163,3 @@ def test_dict_compare():
|
||||
dict1 = {"key1": "value1"}
|
||||
dict2 = {"key1": "value1"}
|
||||
assert node.compare(dict1, dict2) == (True, [], [], [])
|
||||
|
||||
|
||||
def test_any_to_dict():
|
||||
node = AnyToDict()
|
||||
my_dict = {"key1": "value1"}
|
||||
assert node.convert(my_dict) == ({"key1": "value1"},)
|
||||
|
||||
@@ -5,7 +5,6 @@ from src.basic_data_handling.list_nodes import (
|
||||
ListInsert,
|
||||
ListRemove,
|
||||
ListPop,
|
||||
ListClear,
|
||||
ListIndex,
|
||||
ListCount,
|
||||
ListSort,
|
||||
@@ -55,12 +54,6 @@ def test_list_pop():
|
||||
assert node.pop([], 0) == ([], None) # Empty list pop
|
||||
|
||||
|
||||
def test_list_clear():
|
||||
node = ListClear()
|
||||
assert node.clear([1, 2, 3]) == ([],)
|
||||
assert node.clear([]) == ([],)
|
||||
|
||||
|
||||
def test_list_index():
|
||||
node = ListIndex()
|
||||
assert node.index([1, 2, 3, 2], 2) == (1,)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#import pytest
|
||||
from src.basic_data_handling.regex_nodes import (
|
||||
RegexSearchGroups,
|
||||
RegexSearchGroupsDataList,
|
||||
RegexGroupDict,
|
||||
RegexFindall,
|
||||
RegexSplit,
|
||||
RegexFindallDataList,
|
||||
RegexSplitDataList,
|
||||
RegexSub,
|
||||
RegexTest
|
||||
)
|
||||
|
||||
def test_regex_search_groups():
|
||||
node = RegexSearchGroups()
|
||||
node = RegexSearchGroupsDataList()
|
||||
assert node.search_groups(r"(foo)(bar)", "foobar") == (["foo", "bar"],)
|
||||
assert node.search_groups(r"(test)(\d+)", "test123") == (["test", "123"],)
|
||||
assert node.search_groups(r"(nothing)", "no match here") == ([],) # No match
|
||||
@@ -26,7 +26,7 @@ def test_regex_group_dict():
|
||||
|
||||
|
||||
def test_regex_findall():
|
||||
node = RegexFindall()
|
||||
node = RegexFindallDataList()
|
||||
assert node.findall(r"\d+", "abc 123 def 456") == (["123", "456"],)
|
||||
assert node.findall(r"\b[a-zA-Z]+\b", "Multiple words here") == (["Multiple", "words", "here"],)
|
||||
assert node.findall(r"nonexistent", "no match") == ([],) # No match
|
||||
@@ -34,7 +34,7 @@ def test_regex_findall():
|
||||
|
||||
|
||||
def test_regex_split():
|
||||
node = RegexSplit()
|
||||
node = RegexSplitDataList()
|
||||
pattern = r",\s*"
|
||||
string = "one, two, three"
|
||||
assert node.split(pattern, string) == (["one", "two", "three"],)
|
||||
|
||||
@@ -4,7 +4,6 @@ from src.basic_data_handling.set_nodes import (
|
||||
SetRemove,
|
||||
SetDiscard,
|
||||
SetPop,
|
||||
SetClear,
|
||||
SetUnion,
|
||||
SetIntersection,
|
||||
SetDifference,
|
||||
@@ -14,7 +13,6 @@ from src.basic_data_handling.set_nodes import (
|
||||
SetIsDisjoint,
|
||||
SetContains,
|
||||
SetLength,
|
||||
ListToSet,
|
||||
SetToList
|
||||
)
|
||||
|
||||
@@ -47,12 +45,6 @@ def test_set_pop():
|
||||
assert node.pop(empty_set) == (set(), None) # Handle empty set
|
||||
|
||||
|
||||
def test_set_clear():
|
||||
node = SetClear()
|
||||
assert node.clear({1, 2, 3}) == (set(),)
|
||||
assert node.clear(set()) == (set(),) # Already empty set remains empty
|
||||
|
||||
|
||||
def test_set_union():
|
||||
node = SetUnion()
|
||||
assert node.union({1, 2}, {3, 4}) == ({1, 2, 3, 4},)
|
||||
@@ -111,12 +103,6 @@ def test_set_length():
|
||||
assert node.length(set()) == (0,) # Empty set
|
||||
|
||||
|
||||
def test_list_to_set():
|
||||
node = ListToSet()
|
||||
assert node.convert([1, 2, 3, 2]) == ({1, 2, 3},)
|
||||
assert node.convert([]) == (set(),) # Empty list
|
||||
|
||||
|
||||
def test_set_to_list():
|
||||
node = SetToList()
|
||||
result = node.convert({1, 2, 3})
|
||||
|
||||
+46
-10
@@ -6,13 +6,14 @@ from src.basic_data_handling.string_nodes import (
|
||||
StringCenter,
|
||||
StringConcat,
|
||||
StringCount,
|
||||
StringDataListJoin,
|
||||
StringDecode,
|
||||
StringEncode,
|
||||
StringEndswith,
|
||||
StringExpandtabs,
|
||||
StringFind,
|
||||
StringIn,
|
||||
StringFormatMap,
|
||||
StringIn,
|
||||
StringIsAlnum,
|
||||
StringIsAlpha,
|
||||
StringIsAscii,
|
||||
@@ -25,7 +26,8 @@ from src.basic_data_handling.string_nodes import (
|
||||
StringIsSpace,
|
||||
StringIsTitle,
|
||||
StringIsUpper,
|
||||
StringJoin,
|
||||
StringLength,
|
||||
StringListJoin,
|
||||
StringLjust,
|
||||
StringLower,
|
||||
StringLstrip,
|
||||
@@ -34,10 +36,13 @@ from src.basic_data_handling.string_nodes import (
|
||||
StringReplace,
|
||||
StringRfind,
|
||||
StringRjust,
|
||||
StringRsplit,
|
||||
StringRsplitDataList,
|
||||
StringRsplitList,
|
||||
StringRstrip,
|
||||
StringSplit,
|
||||
StringSplitlines,
|
||||
StringSplitDataList,
|
||||
StringSplitList,
|
||||
StringSplitlinesDataList,
|
||||
StringSplitlinesList,
|
||||
StringStartswith,
|
||||
StringStrip,
|
||||
StringSwapcase,
|
||||
@@ -211,12 +216,18 @@ def test_isupper():
|
||||
assert node.isupper("") == (False,) # Empty string
|
||||
|
||||
def test_join():
|
||||
node = StringJoin()
|
||||
node = StringDataListJoin()
|
||||
# join expects a data list as input, so we need to simulate this
|
||||
assert node.join([", "], ["apple", "banana", "cherry"]) == ("apple, banana, cherry",)
|
||||
assert node.join([""], ["a", "b", "c"]) == ("abc",)
|
||||
assert node.join(["-"], []) == ("",) # Empty list
|
||||
|
||||
# Test ListJoin variant
|
||||
node_list = StringListJoin()
|
||||
assert node_list.join([", "], ["apple", "banana", "cherry"]) == ("apple, banana, cherry",)
|
||||
assert node_list.join([""], ["a", "b", "c"]) == ("abc",)
|
||||
assert node_list.join(["-"], []) == ("",) # Empty list
|
||||
|
||||
def test_ljust():
|
||||
node = StringLjust()
|
||||
assert node.ljust("test", 10) == ("test ",)
|
||||
@@ -269,11 +280,17 @@ def test_rjust():
|
||||
assert node.rjust("test", 2) == ("test",) # Width smaller than string length
|
||||
|
||||
def test_rsplit():
|
||||
node = StringRsplit()
|
||||
node = StringRsplitDataList()
|
||||
assert node.rsplit("apple,banana,cherry", ",") == (["apple", "banana", "cherry"],)
|
||||
assert node.rsplit("apple,banana,cherry", ",", 1) == (["apple,banana", "cherry"],)
|
||||
assert node.rsplit(" words with spaces ") == (["words", "with", "spaces"],) # Default splits on whitespace
|
||||
|
||||
# Test List variant
|
||||
node_list = StringRsplitList()
|
||||
assert node_list.rsplit("apple,banana,cherry", ",") == (["apple", "banana", "cherry"],)
|
||||
assert node_list.rsplit("apple,banana,cherry", ",", 1) == (["apple,banana", "cherry"],)
|
||||
assert node_list.rsplit(" words with spaces ") == (["words", "with", "spaces"],) # Default splits on whitespace
|
||||
|
||||
def test_rstrip():
|
||||
node = StringRstrip()
|
||||
assert node.rstrip("hello ") == ("hello",)
|
||||
@@ -282,18 +299,31 @@ def test_rstrip():
|
||||
assert node.rstrip("") == ("",) # Empty string
|
||||
|
||||
def test_split():
|
||||
node = StringSplit()
|
||||
node = StringSplitDataList()
|
||||
assert node.split("apple,banana,cherry", ",") == (["apple", "banana", "cherry"],)
|
||||
assert node.split("apple,banana,cherry", ",", 1) == (["apple", "banana,cherry"],)
|
||||
assert node.split(" words with spaces ") == (["words", "with", "spaces"],) # Default splits on whitespace
|
||||
|
||||
# Test List variant
|
||||
node_list = StringSplitList()
|
||||
assert node_list.split("apple,banana,cherry", ",") == (["apple", "banana", "cherry"],)
|
||||
assert node_list.split("apple,banana,cherry", ",", 1) == (["apple", "banana,cherry"],)
|
||||
assert node_list.split(" words with spaces ") == (["words", "with", "spaces"],) # Default splits on whitespace
|
||||
|
||||
def test_splitlines():
|
||||
node = StringSplitlines()
|
||||
node = StringSplitlinesDataList()
|
||||
assert node.splitlines("line1\nline2\nline3") == (["line1", "line2", "line3"],)
|
||||
assert node.splitlines("line1\r\nline2\rline3") == (["line1", "line2", "line3"],)
|
||||
assert node.splitlines("line1\nline2\nline3", "True") == (["line1\n", "line2\n", "line3"],) # Keep line endings
|
||||
assert node.splitlines("line1\nline2\nline3", True) == (["line1\n", "line2\n", "line3"],) # Keep line endings
|
||||
assert node.splitlines("no newlines") == (["no newlines"],)
|
||||
|
||||
# Test List variant
|
||||
node_list = StringSplitlinesList()
|
||||
assert node_list.splitlines("line1\nline2\nline3") == (["line1", "line2", "line3"],)
|
||||
assert node_list.splitlines("line1\r\nline2\rline3") == (["line1", "line2", "line3"],)
|
||||
assert node_list.splitlines("line1\nline2\nline3", True) == (["line1\n", "line2\n", "line3"],) # Keep line endings
|
||||
assert node_list.splitlines("no newlines") == (["no newlines"],)
|
||||
|
||||
def test_startswith():
|
||||
node = StringStartswith()
|
||||
assert node.startswith("function startswith", "function") == (True,)
|
||||
@@ -333,3 +363,9 @@ def test_zfill():
|
||||
assert node.zfill("-123", 5) == ("-0123",) # Preserves sign
|
||||
assert node.zfill("123", 2) == ("123",) # Width smaller than string length
|
||||
assert node.zfill("", 3) == ("000",) # Empty string
|
||||
|
||||
def test_length():
|
||||
node = StringLength()
|
||||
assert node.length("hello") == (5,)
|
||||
assert node.length("") == (0,) # Empty string
|
||||
assert node.length("hello world") == (11,) # String with spaces
|
||||
|
||||
Reference in New Issue
Block a user