Skip to content

Commit bdb16e6

Browse files
committed
Add more test coverage for MassTable
1 parent 40abc4d commit bdb16e6

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

tests/test_mass_table.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ def empty_frame():
1010
return MassTable(df=pd.DataFrame())
1111

1212

13+
def test_initial_complete_parse():
14+
data = MassTable().df
15+
expected_shape = (21421, 50)
16+
17+
assert expected_shape == data.shape
18+
19+
1320
def test_getter_creation():
1421
cols = ["Mass", "Error", "Param", "RandomLongerString"]
1522
test_frame = pd.DataFrame.from_dict(data=dict.fromkeys(cols, [0]))
@@ -56,6 +63,26 @@ def test_auto_populated_filter():
5663
assert f_df._filters == [(cols[0], "==", val)]
5764

5865

66+
def test_getter_on_index():
67+
cols = ["Mass", "Error", "Param", "RandomLongerString"]
68+
test_frame = pd.DataFrame.from_dict(data=dict.fromkeys(cols, [0]))
69+
70+
m_df = MassTable(df=test_frame)
71+
m_df.set_index("Param")
72+
m_df = m_df.get_Param(0).df
73+
74+
expected = pd.DataFrame(
75+
{
76+
"Mass": [0],
77+
"Error": [0],
78+
"Param": [0],
79+
"RandomLongerString": [0],
80+
}
81+
)
82+
83+
pdt.assert_frame_equal(m_df, expected, check_like=True)
84+
85+
5986
def test_access_property():
6087
cols = ["Mass", "Error", "Param", "RandomLongerString"]
6188
test_frame = pd.DataFrame.from_dict(data=dict.fromkeys(cols, [0]))
@@ -72,3 +99,39 @@ def test_access_property():
7299
)
73100

74101
pdt.assert_frame_equal(m_df, expected, check_like=True)
102+
103+
104+
def test_generic_getter():
105+
cols = ["Mass", "Error", "Param", "RandomLongerString"]
106+
test_frame = pd.DataFrame.from_dict(data=dict.fromkeys(cols, [0]))
107+
108+
m_df = MassTable(df=test_frame).get("Error", 0).df
109+
110+
expected = pd.DataFrame(
111+
{
112+
"Mass": [0],
113+
"Error": [0],
114+
"Param": [0],
115+
"RandomLongerString": [0],
116+
}
117+
)
118+
119+
pdt.assert_frame_equal(m_df, expected, check_like=True)
120+
121+
122+
def test_generic_filter():
123+
cols = ["Mass", "Error", "Param", "RandomLongerString"]
124+
test_frame = pd.DataFrame.from_dict(data=dict.fromkeys(cols, [0]))
125+
126+
m_df = MassTable(df=test_frame).filter("Param == 0").df
127+
128+
expected = pd.DataFrame(
129+
{
130+
"Mass": [0],
131+
"Error": [0],
132+
"Param": [0],
133+
"RandomLongerString": [0],
134+
}
135+
)
136+
137+
pdt.assert_frame_equal(m_df, expected, check_like=True)

0 commit comments

Comments
 (0)