From: Brian Warner <warner@lothar.com>
Date: Wed, 31 Oct 2007 07:54:42 +0000 (-0700)
Subject: test_node.py: improve test coverage of node.py
X-Git-Tag: allmydata-tahoe-0.7.0~340
X-Git-Url: https://git.rkrishnan.org/pf/content/%22news.html/frontends/quickstart.html?a=commitdiff_plain;h=22e3487b9e0720f864feef6cf06238e9af82aa7d;p=tahoe-lafs%2Ftahoe-lafs.git

test_node.py: improve test coverage of node.py
---

diff --git a/src/allmydata/test/test_node.py b/src/allmydata/test/test_node.py
index 9877a159..f55e99a1 100644
--- a/src/allmydata/test/test_node.py
+++ b/src/allmydata/test/test_node.py
@@ -1,11 +1,12 @@
 
+import time
 from twisted.trial import unittest
 from twisted.internet import defer
 from twisted.python import log
 
 from foolscap.eventual import flushEventualQueue
 from twisted.application import service
-from allmydata.node import Node
+from allmydata.node import Node, formatTimeTahoeStyle
 from allmydata.util import testutil
 
 class LoggingMultiService(service.MultiService):
@@ -40,3 +41,18 @@ class TestCase(unittest.TestCase, testutil.SignalMixin):
         d.addCallback(_check_addresses)
         return d
 
+    def test_log(self):
+        n = TestNode()
+        n.log("this is a message")
+        n.log("with %d %s %s", args=(2, "interpolated", "parameters"))
+
+    def test_timestamp(self):
+        # this modified logger doesn't seem to get used during the tests,
+        # probably because we don't modify the LogObserver that trial
+        # installs (only the one that twistd installs). So manually exercise
+        # it a little bit.
+        t = formatTimeTahoeStyle("ignored", time.time())
+        self.failUnless("Z" in t)
+        t2 = formatTimeTahoeStyle("ignored", int(time.time()))
+        self.failUnless("Z" in t2)
+