Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
manage campaign that can not be send
Browse files Browse the repository at this point in the history
  • Loading branch information
skoudoro committed Jan 9, 2022
1 parent 33525a7 commit 4f2fdc7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mailerlite/tests/test_campaign.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module to tests Campaign."""
import random

import pytest

Expand Down Expand Up @@ -143,11 +144,16 @@ def test_cancel_send_campaign(header):
campaign_obj = Campaigns(header)

if campaign_obj.count('outbox'):
res = campaign_obj.all(status='outbox', limit=5)
res = campaign_obj.all(status='outbox', limit=10)
if not res:
pytest.skip("No campaign found with outbox status")
assert res[0].status == 'outbox'
code, res_2 = campaign_obj.cancel(res[0].id)

campaign_idx = random.randint(0, len(res))
assert res[campaign_idx].status == 'outbox'
try:
code, res_2 = campaign_obj.cancel(res[campaign_idx].id)
except OSError:
pytest.skip("Campaign Not Found so can not be cancel")
assert code == 200
assert res_2["status"] == 'draft'
assert res[0].id == res_2["id"]

0 comments on commit 4f2fdc7

Please sign in to comment.