Closed hawkins closed 7 years ago
It looks like using MiniMock should make mocking SMTP / IMAP calls feasible. If we go that route, it looks like testing receiving an actual message will be tough - so I'm thinking we'll just spoof calls to the handlers that we'll test anyway. That assumes that IMAP can connect and receive messages, and we'll later assume that IMAP can also modify labels of messages. That doesn't seem too unreasonable, assuming users are able to connect to the IMAP server in the first place.
So a lot of assumptions in that route - but I think most of them are fair.
Furthermore, I think I'll write a module to spoof a phone that we can use for interactive teststhat simulates SMS interactions with a Shawk Client. It'll provide a means to spoof a Client's IMAP connection receiving messages, so its messages will be handled by the message handlers, without ever actually interacting with SMTP or IMAP. This may be useful for custom user interaction testing, so it may be worth packaging it as shawk.Spoofer
or similar.
Finally, looks like using PyTest ($ pip install pytest
) is the way to go here. I've started creating a test suite over on the 'test' branch.
This one's been a long time coming...
Until now, I've been painstakingly and manually testing each and every feature with a
test.py
file I've gitignored. Mostly because testing requires a Gmail account and a phone number to test with. So I'd write a quick Shawk script, add some behaviors, and test whatever feature or bug I needed to with my own Gmail and phone.I'd like to build a test suite that incorporates an email 'spoofer' in a sense that it...
The first being a requirement, and the second being a nicety.
What I can see we need is a means to spoof an email address like "1234567890@vtext.com" to spoof a Verizon address, and an IMAP server to spoof. The IMAP server spoof may be unnecessary, since we can limit its impact on the outside world. For instance, ideally, we could prevent replying to spoofed numbers somehow - so maybe our
__sendmail()
function is just disabled entirely. We know it works, so we can instead wire this test Shawk instance up to print the input passed to__sendmail()
to determine what would happen. That way we can test IMAP features like moving folders, but can't impact the outside world beyond that.Additionally, we could configure the IMAP server to be read only. Not sure that's necessary or useful, though.
Would like to incorporate pytest for this effort.