diff options
Diffstat (limited to 'tests/test_status.py')
-rw-r--r-- | tests/test_status.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/test_status.py b/tests/test_status.py index 5c139e6..20e32f2 100644 --- a/tests/test_status.py +++ b/tests/test_status.py | |||
@@ -186,4 +186,30 @@ def test_scheduled_status(api): | |||
186 | scheduled_toot_list_3 = api.scheduled_statuses() | 186 | scheduled_toot_list_3 = api.scheduled_statuses() |
187 | assert scheduled_toot_4.id in map(lambda x: x.id, statuses) | 187 | assert scheduled_toot_4.id in map(lambda x: x.id, statuses) |
188 | assert not scheduled_toot_4.id in map(lambda x: x.id, scheduled_toot_list_3) | 188 | assert not scheduled_toot_4.id in map(lambda x: x.id, scheduled_toot_list_3) |
189 | \ No newline at end of file | 189 | |
190 | # The following two tests need to be manually (!) ran 10 minutes apart when recording. | ||
191 | # Sorry, I can't think of a better way to test scheduled statuses actually work as intended. | ||
192 | @pytest.mark.vcr(match_on=['path']) | ||
193 | def test_scheduled_status_long_part1(api): | ||
194 | with vcr.use_cassette('test_scheduled_status_long_part1.yaml', cassette_library_dir='tests/cassettes_special', record_mode='once'): | ||
195 | if os.path.exists("tests/cassettes_special/test_scheduled_status_long_datetimeobjects.pkl"): | ||
196 | the_medium_term_future = datetime.datetime.fromtimestamp(pickle.load(open("tests/cassettes_special/test_scheduled_status_long_datetimeobjects.pkl", 'rb'))) | ||
197 | else: | ||
198 | the_medium_term_future = datetime.datetime.now() + datetime.timedelta(minutes=6) | ||
199 | pickle.dump(the_medium_term_future.timestamp(), open("tests/cassettes_special/test_scheduled_status_long_datetimeobjects.pkl", 'wb')) | ||
200 | scheduled_toot = api.status_post("please ensure maximum headroom at " + str(the_medium_term_future), scheduled_at=the_medium_term_future) | ||
201 | scheduled_toot_list = api.scheduled_statuses() | ||
202 | assert scheduled_toot.id in map(lambda x: x.id, scheduled_toot_list) | ||
203 | pickle.dump(scheduled_toot.params.text, open("tests/cassettes_special/test_scheduled_status_long_text.pkl", 'wb')) | ||
204 | |||
205 | @pytest.mark.vcr(match_on=['path']) | ||
206 | def test_scheduled_status_long_part2(api): | ||
207 | with vcr.use_cassette('test_scheduled_status_long_part2.yaml', cassette_library_dir='tests/cassettes_special', record_mode='once'): | ||
208 | text = pickle.load(open("tests/cassettes_special/test_scheduled_status_long_text.pkl", 'rb')) | ||
209 | statuses = api.timeline_home() | ||
210 | print(text) | ||
211 | found_status = False | ||
212 | for status in statuses: | ||
213 | if text in status.content: | ||
214 | found_status = True | ||
215 | assert found_status | ||