http://code.google.com/p/appengine-afterburner/source/detail?r=33
Modified:
/trunk/python/src/afterburner/experimental/samplez/samplez_test.py
=======================================
--- /trunk/python/src/afterburner/experimental/samplez/samplez_test.py Mon
Jul 18 17:27:33 2011
+++ /trunk/python/src/afterburner/experimental/samplez/samplez_test.py Mon
Jul 18 17:54:05 2011
@@ -947,6 +947,28 @@
## handler.get()
## self.assertTrue('Samplez sections' in response.out.getvalue())
+ def testMode(self):
+ """Tests using the module in test mode."""
+ section = samplez.Section(
+ 'My section',
+ samplez.Config(
+ 'first',
+ period=300,
+ rate=1,
+ samples=10000,
+ by_value=True))
+
+ # Just doing a set won't work because test mode isn't setup yet.
+ samplez.set(section, 'my key', 9999)
+
+ # Once test mode is setup then samples will be recorded.
+ samplez.setup_for_testing()
+ samplez.set(section, 'my key', 1234)
+ self.assertEquals([0], [r.get_count('my key') for r in
section.results()])
+
+ samplez.apply_for_testing()
+ self.assertEquals([1], [r.get_count('my key') for r in
section.results()])
+
def testConfig(self):
"""Tests config validation."""
# Bad name.