mirror of
https://github.com/chatmail/relay.git
synced 2026-05-21 13:28:05 +00:00
improved test but still not doing what it should
This commit is contained in:
@@ -52,6 +52,7 @@ class SmtpConn:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def gencreds(maildomain):
|
def gencreds(maildomain):
|
||||||
count = itertools.count()
|
count = itertools.count()
|
||||||
|
next(count)
|
||||||
|
|
||||||
def gen():
|
def gen():
|
||||||
while 1:
|
while 1:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import random
|
import random
|
||||||
import pytest
|
import pytest
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class TestMailSending:
|
class TestMailSending:
|
||||||
@@ -36,18 +37,22 @@ class TestMailSending:
|
|||||||
msgs.append(msg)
|
msgs.append(msg)
|
||||||
lp.indent(f"Sent out msg {i}, size {attachsize/(1024*1024)}MB")
|
lp.indent(f"Sent out msg {i}, size {attachsize/(1024*1024)}MB")
|
||||||
|
|
||||||
lp.sec("ac2: check that at least one message failed due to quota")
|
lp.sec("ac2: check messages are arriving until quota is reached")
|
||||||
bytes_sent = 0
|
bytes_sent = 0
|
||||||
for i, msg in enumerate(msgs):
|
for i, msg in enumerate(msgs):
|
||||||
# wait for the message to be received
|
# wait for the message to be received or to fail
|
||||||
msg_received = ac2.wait_next_incoming_message()
|
start = time.time()
|
||||||
if msg.is_out_failed():
|
while time.time() < (start + 30):
|
||||||
assert bytes_sent + 10 * 1024*1024 > quota, "quota kicked in too early"
|
if msg.is_out_delivered():
|
||||||
lp.indent("good, message sending failed because quota was exceeded")
|
bytes_sent += attachsize
|
||||||
lp.indent(chat.get_messages()[i].get_message_info())
|
mb = bytes_sent // (1024*1024)
|
||||||
return
|
lp.indent(f"message {i} success, bytes transmitted so far {mb}MB")
|
||||||
assert msg.is_out_delivered(), msg.get_message_info()
|
break
|
||||||
bytes_sent += attachsize
|
elif msg.is_out_failed():
|
||||||
mb = bytes_sent // (1024*1024)
|
assert i > num_to_send/2, "quota kicked in too early"
|
||||||
lp.indent(f"message {i} success, bytes transmitted so far {mb}MB")
|
lp.indent("good, message sending failed because quota was exceeded")
|
||||||
|
lp.indent(chat.get_messages()[i].get_message_info())
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
pytest.fail("sending succeeded although messages should exceed quota")
|
pytest.fail("sending succeeded although messages should exceed quota")
|
||||||
|
|||||||
Reference in New Issue
Block a user