Skip to content

Commit 39980fd

Browse files
committed
Simplify new tests added
* Since int columns will be converted to float if there are unmatched rows, I use `check_dtype=False` but still use nullable int in the assumed correct table.
1 parent e32023c commit 39980fd

File tree

3 files changed

+93
-344
lines changed

3 files changed

+93
-344
lines changed

tests/integration/fixtures.py

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -88,83 +88,45 @@ def datetime_table():
8888

8989
@pytest.fixture
9090
def user_table_lk():
91-
# Link table identified by id and date range (startdate and enddate)
91+
# Link table identified by id and startdate
9292
# Used for query with both equality and inequality conditions
9393
out = pd.DataFrame(
94-
[
95-
[0, 0, 2, pd.NA, 110, "a1", 1.1, pd.Timestamp("2001-01-01")],
96-
[0, 4, 6, pd.NA, 111, "a2", 1.2, pd.Timestamp("2001-02-01")],
97-
[1, 2, 5, pd.NA, 112, "a3", np.nan, pd.Timestamp("2001-03-01")],
98-
[1, 4, 6, 13, 113, "a4", np.nan, pd.Timestamp("2001-04-01")],
99-
[3, 1, 2, 14, 114, "a5", np.nan, pd.NaT],
100-
[3, 2, 3, 15, 115, "a6", 1.6, pd.NaT],
101-
],
102-
columns=[
103-
"id",
104-
"startdate",
105-
"enddate",
106-
"lk_nullint",
107-
"lk_int",
108-
"lk_str",
109-
"lk_float",
110-
"lk_date",
111-
],
94+
[[0, 5, 11, 111], [1, 2, pd.NA, 112], [1, 4, 13, 113], [3, 1, 14, 114],],
95+
columns=["id", "startdate", "lk_nullint", "lk_int"],
11296
)
11397
out["lk_nullint"] = out["lk_nullint"].astype("Int32")
114-
out["lk_str"] = out["lk_str"].astype("string")
11598
return out
11699

117100

118101
@pytest.fixture
119102
def user_table_lk2(user_table_lk):
120-
# Link table identified by only date range (startdate and enddate)
103+
# Link table identified by startdate only
121104
# Used for query with inequality conditions
122-
return user_table_lk.set_index("id").loc[1].reset_index(drop=True)
105+
out = pd.DataFrame(
106+
[[2, pd.NA, 112], [4, 13, 113],], columns=["startdate", "lk_nullint", "lk_int"],
107+
)
108+
out["lk_nullint"] = out["lk_nullint"].astype("Int32")
109+
return out
123110

124111

125112
@pytest.fixture
126113
def user_table_ts():
127114
# A table of time-series data identified by dates
128115
out = pd.DataFrame(
129-
[
130-
[3, pd.NA, 221, "b1", 2.1, pd.Timestamp("2002-01-01")],
131-
[4, 22, 222, "b2", np.nan, pd.Timestamp("2002-02-01")],
132-
[7, 23, 223, "b3", 2.3, pd.NaT],
133-
],
134-
columns=["dates", "ts_nullint", "ts_int", "ts_str", "ts_float", "ts_date"],
116+
[[1, 21], [3, pd.NA], [7, 23],], columns=["dates", "ts_nullint"],
135117
)
136118
out["ts_nullint"] = out["ts_nullint"].astype("Int32")
137-
out["ts_str"] = out["ts_str"].astype("string")
138119
return out
139120

140121

141122
@pytest.fixture
142123
def user_table_pn():
143124
# A panel table identified by id and dates
144125
out = pd.DataFrame(
145-
[
146-
[0, 1, pd.NA, 331, "c1", 3.1, pd.Timestamp("2003-01-01")],
147-
[0, 2, pd.NA, 332, "c2", 3.2, pd.Timestamp("2003-02-01")],
148-
[0, 3, pd.NA, 333, "c3", 3.3, pd.Timestamp("2003-03-01")],
149-
[1, 3, pd.NA, 334, "c4", np.nan, pd.Timestamp("2003-04-01")],
150-
[1, 4, 35, 335, "c5", np.nan, pd.Timestamp("2003-05-01")],
151-
[2, 1, 36, 336, "c6", np.nan, pd.Timestamp("2003-06-01")],
152-
[2, 3, 37, 337, "c7", np.nan, pd.NaT],
153-
[3, 2, 38, 338, "c8", 3.8, pd.NaT],
154-
[3, 2, 39, 339, "c9", 3.9, pd.NaT],
155-
],
156-
columns=[
157-
"ids",
158-
"dates",
159-
"pn_nullint",
160-
"pn_int",
161-
"pn_str",
162-
"pn_float",
163-
"pn_date",
164-
],
126+
[[0, 1, pd.NA], [1, 5, 32], [2, 1, 33],],
127+
columns=["ids", "dates", "pn_nullint"],
165128
)
166129
out["pn_nullint"] = out["pn_nullint"].astype("Int32")
167-
out["pn_str"] = out["pn_str"].astype("string")
168130
return out
169131

170132

0 commit comments

Comments
 (0)