Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding --version switch to commands. test fixes.

  • Loading branch information...
commit fb8a98d86b628c2649d917986c97504e17edc875 1 parent e47fb1c
@mcfunley authored
View
3  README.md
@@ -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
2  oplogutils/__init__.py
@@ -1,5 +1,5 @@
from _trimmer import Trimmer
from _counter import Counter
-__version__ = '0.1.1'
+__version__ = '0.1.2'
View
11 oplogutils/_core.py
@@ -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,6 +48,11 @@ 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.')
@@ -52,6 +60,9 @@ def common_options(self, op):
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
2  setup.py
@@ -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
9 test/test_core.py
@@ -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
8 test/test_counter.py
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.