Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add TestingHarold to testing.

  • Loading branch information...
commit 32d3234c5d820be8145b88b108d27cd7e035a238 1 parent 85284e1
Logan Hanks authored
Showing with 18 additions and 0 deletions.
  1. +17 −0 testing.py
  2. +1 −0  testing_test.py
View
17 testing.py
@@ -1,5 +1,7 @@
import tempfile
+import wessex
+
import alerts
def stub(namespace, name):
@@ -24,7 +26,20 @@ def wrapped(*args, **kwargs):
return wrapped
return decorator
+class TestingHarold(wessex.Harold):
+ def __init__(self, *args, **kwargs):
+ super(TestingHarold, self).__init__(*args, **kwargs)
+ self.reset_for_testing()
+
+ def _post_to_harold(self, path, data):
+ self.post_log.append((path, data))
+
+ def reset_for_testing(self):
+ self.post_log = []
+
+@stub(wessex, 'Harold')
def init_alerts(**sections):
+ wessex.Harold = TestingHarold
config = dict(
harold=dict(host='localhost', port=8888, secret='secret'),
)
@@ -37,3 +52,5 @@ def init_alerts(**sections):
f.write('\n')
f.flush()
alerts.init(config_path=f.name)
+
+
View
1  testing_test.py
@@ -49,6 +49,7 @@ def test_init(self):
self.assertEquals(8888, alerts.harold.port)
self.assertEquals('secret', alerts.harold.secret)
self.assertEquals(1, alerts.config.getint('custom1', 'a'))
+ self.assertTrue(isinstance(alerts.harold, testing.TestingHarold))
if __name__ == '__main__':
unittest.main()
Please sign in to comment.
Something went wrong with that request. Please try again.