Skip to content

Commit b660c19

Browse files
committed
test microsecond too
1 parent a459274 commit b660c19

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

tests/column/temporal/components_test.py

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
def test_expr_components(library: str, attr: str, expected: list[int]) -> None:
2121
df = temporal_dataframe_1(library)
2222
col = df.__dataframe_namespace__().col
23-
result = df.select(getattr(col("a").dt, attr)())
24-
result_list = result.collect().get_column_by_name("a")
25-
assert result_list.get_value(0) == expected[0]
26-
assert result_list.get_value(1) == expected[1]
27-
assert result_list.get_value(2) == expected[2]
23+
for col_name in ("a", "c", "e"):
24+
result = df.select(getattr(col(col_name).dt, attr)())
25+
result_list = result.collect().get_column_by_name(col_name)
26+
assert result_list.get_value(0) == expected[0]
27+
assert result_list.get_value(1) == expected[1]
28+
assert result_list.get_value(2) == expected[2]
2829

2930

3031
@pytest.mark.parametrize(
@@ -41,7 +42,42 @@ def test_expr_components(library: str, attr: str, expected: list[int]) -> None:
4142
)
4243
def test_col_components(library: str, attr: str, expected: list[int]) -> None:
4344
df = temporal_dataframe_1(library).collect()
44-
result = getattr(df.get_column_by_name("a").dt, attr)()
45+
for col_name in ("a", "c", "e"):
46+
result = getattr(df.get_column_by_name(col_name).dt, attr)()
47+
assert result.get_value(0) == expected[0]
48+
assert result.get_value(1) == expected[1]
49+
assert result.get_value(2) == expected[2]
50+
51+
52+
@pytest.mark.parametrize(
53+
("col_name", "expected"),
54+
[
55+
("a", [123000, 321000, 987000]),
56+
("c", [123543, 321654, 987321]),
57+
("e", [123543, 321654, 987321]),
58+
],
59+
)
60+
def test_expr_microsecond(library: str, col_name: str, expected: list[int]) -> None:
61+
df = temporal_dataframe_1(library)
62+
col = df.__dataframe_namespace__().col
63+
result = df.select(col(col_name).dt.microsecond())
64+
result_list = result.collect().get_column_by_name(col_name)
65+
assert result_list.get_value(0) == expected[0]
66+
assert result_list.get_value(1) == expected[1]
67+
assert result_list.get_value(2) == expected[2]
68+
69+
70+
@pytest.mark.parametrize(
71+
("col_name", "expected"),
72+
[
73+
("a", [123000, 321000, 987000]),
74+
("c", [123543, 321654, 987321]),
75+
("e", [123543, 321654, 987321]),
76+
],
77+
)
78+
def test_col_microsecond(library: str, col_name: str, expected: list[int]) -> None:
79+
df = temporal_dataframe_1(library).collect()
80+
result = df.get_column_by_name(col_name).dt.microsecond()
4581
assert result.get_value(0) == expected[0]
4682
assert result.get_value(1) == expected[1]
4783
assert result.get_value(2) == expected[2]

0 commit comments

Comments
 (0)