1 from shutil
import rmtree
8 from test_app
.config
import settings
as server_settings
10 from salmon
import queue
12 from .setup_env
import SalmonTestCase
, dirs
15 class IntegrationTestCase(SalmonTestCase
):
18 cls
._cwd
= "tests/data/test_app"
20 rmtree(os
.path
.join(cls
._cwd
, path
), ignore_errors
=True)
21 os
.mkdir(os
.path
.join(cls
._cwd
, path
))
22 cls
._server
= subprocess
.Popen(["salmon", "start", "--boot", "config.dump", "--no-daemon"],
23 cwd
=cls
._cwd
, stdout
=sys
.stdout
, stderr
=sys
.stderr
)
26 conn
= smtplib
.SMTP(**server_settings
.receiver_config
)
34 raise Exception("Server still not ready, something must be wrong")
37 def tearDownClass(cls
):
41 rmtree(os
.path
.join(cls
._cwd
, path
), ignore_errors
=True)
45 # re-create destoryed queues
46 queue
.Queue(os
.path
.join(self
._cwd
, server_settings
.UNDELIVERABLE_QUEUE
)).clear()
47 queue
.Queue(os
.path
.join(self
._cwd
, server_settings
.QUEUE_PATH
)).clear()
49 def test_we_get_message(self
):
50 client
= smtplib
.SMTP(**server_settings
.receiver_config
)
53 client
.sendmail("me@example.com", "you@example.com", "hello")
55 undelivered
= queue
.Queue(os
.path
.join(self
._cwd
, server_settings
.UNDELIVERABLE_QUEUE
))
56 self
.assertEqual(len(undelivered
), 0)
58 inbox
= queue
.Queue(os
.path
.join(self
._cwd
, server_settings
.QUEUE_PATH
))
59 self
.assertEqual(len(inbox
), 1)
61 def test_we_dont_get_message(self
):
62 client
= smtplib
.SMTP(**server_settings
.receiver_config
)
65 client
.sendmail("me@example.com", "you@example1.com", "hello")
67 undelivered
= queue
.Queue(os
.path
.join(self
._cwd
, server_settings
.UNDELIVERABLE_QUEUE
))
68 self
.assertEqual(len(undelivered
), 1)
70 inbox
= queue
.Queue(os
.path
.join(self
._cwd
, server_settings
.QUEUE_PATH
))
71 self
.assertEqual(len(inbox
), 0)