Permalink
Browse files

adding --version switch to commands. test fixes.

  • Loading branch information...
mcfunley committed May 30, 2010
1 parent e47fb1c commit fb8a98d86b628c2649d917986c97504e17edc875
Showing with 27 additions and 8 deletions.
  1. +3 −0 README.md
  2. +1 −1 oplogutils/__init__.py
  3. +11 −0 oplogutils/_core.py
  4. +1 −1 setup.py
  5. +7 −2 test/test_core.py
  6. +4 −4 test/test_counter.py
View
@@ -58,6 +58,9 @@ python setup.py test
## Version History
+### Version 0.1.2
+* 05-30-2010 - Added --version switch to commands. Test fixes.
+
### Version 0.1.1
* 05-30-2010 - Added oplogutils to cheeseshop.
View
@@ -1,5 +1,5 @@
from _trimmer import Trimmer
from _counter import Counter
-__version__ = '0.1.1'
+__version__ = '0.1.2'
View
@@ -34,6 +34,9 @@ def __init__(self):
self.common_options(self.option_parser)
self.opts, self.args = self.option_parser.parse_args()
+ if self.opts.version:
+ self.show_version()
+
if not self.opts.host:
self.usage_error()
@@ -45,13 +48,21 @@ def usage_error(self):
sys.exit(-1)
+ def show_version(self):
+ print 'OPLOGUTILS version', sys.modules['oplogutils'].__version__
+ sys.exit(0)
+
+
def common_options(self, op):
op.add_option('', '--host', action='store', dest='host', default=None,
help='The hostname of the mongodb master instance.')
op.add_option('', '--port', action='store', dest='port', type='int',
default=27017,
help=('The port of the mongodb master instance. (Defaults '
'to 27017.)'))
+ op.add_option('', '--version', action='store_true', dest='version',
+ default=False,
+ help='Display version information and exit.')
return op
View
@@ -9,7 +9,7 @@
setup(
name = 'oplogutils',
- version = '0.1.1',
+ version = '0.1.2',
author = 'Dan McKinley',
author_email = 'dan@etsy.com',
description = 'A oplog editing utility for mongodb.',
View
@@ -2,7 +2,8 @@
import unittest
from oplogutils import _core
from optparse import OptionParser
-from util import output_to_string, args
+from util import output_to_string, args, Test
+import re
class MockCommand(_core.Command):
@@ -17,7 +18,11 @@ def run(self):
-class CoreTests(unittest.TestCase):
+class CoreTests(Test):
+
+ def test_version(self):
+ txt = self.run_command(MockCommand, ['--version'], 0)
+ self.assertTrue(re.match('\s*OPLOGUTILS version [0-9.]+\s*', txt))
def test_timestamp(self):
View
@@ -1,6 +1,6 @@
from __future__ import with_statement
import unittest
-from util import output_to_string, args, Test
+from util import output_to_string, args, Test, mutates_oplog
import settings
from oplogutils import Counter
import re
@@ -80,10 +80,10 @@ def test_end_before_start(self):
def test_start_and_end(self):
+ d = self.oplog().find_one()['ts'].as_datetime()
day = timedelta(1)
- now = datetime.now()
- start = str(now - day)[:19]
- end = str(now + day)[:19]
+ start = str(d - day)[:19]
+ end = str(d + day)[:19]
m = re.match(re_start + ' between (.*) and (.*) \(UTC\)\.',
self.count('--start=%s' % start, '--end=%s' % end))
self.assertTrue(m)

0 comments on commit fb8a98d

Please sign in to comment.