Skip to content

Commit c630d9a

Browse files
Add margin to number of results in snowball tests
This commit adds a margin to the allowed number of results in the snowballing tests. This way, if OpenAlex changes the data, the tests still pass.
1 parent d1d78e2 commit c630d9a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/test_snowball.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ def test_openalex_id_backward(tmpdir):
122122
email=EMAIL,
123123
)
124124
df = pd.read_csv(out_fp)
125-
assert len(df) == 40
125+
# Actual value at time of writing test is 40 (2024-08-26).
126+
# In theory the number of results should be stable for backward snowballing,
127+
# but OpenAlex sometimes makes changes, so we allow for a margin.
128+
# The margins of this assert and the next assert should not overlap,
129+
# otherwise we don't test if 'use_all' works.
130+
assert 38 <= len(df) <= 42
126131

127132
all_out_fp = Path(tmpdir, "backward_all.csv")
128133
snowball(
@@ -134,7 +139,8 @@ def test_openalex_id_backward(tmpdir):
134139
email=EMAIL,
135140
)
136141
df_all = pd.read_csv(all_out_fp)
137-
assert len(df_all) == 45
142+
# Actual value at time of writing test is 46 (2024-08-26).
143+
assert 43 <= len(df_all) <= 49
138144

139145

140146
def test_snowballing_from_doi(tmpdir):
@@ -148,4 +154,6 @@ def test_snowballing_from_doi(tmpdir):
148154
email=EMAIL,
149155
)
150156
df = pd.read_csv(out_fp)
151-
assert len(df) == 45
157+
# Actual value at time of writing test is 46 (2024-08-26).
158+
# See comments in 'test_openalex_id_backward'.
159+
assert 43 <= len(df) <= 49

0 commit comments

Comments
 (0)