Commit 13be464f authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

merged trac #411 (TTL parser bug)


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@3599 e5f2f494-b856-4b98-b285-d166d9295462
parents 9afb5766 26c6fdf2
......@@ -493,6 +493,7 @@ AC_CONFIG_FILES([Makefile
src/lib/python/isc/util/Makefile
src/lib/python/isc/util/tests/Makefile
src/lib/python/isc/datasrc/Makefile
src/lib/python/isc/datasrc/tests/Makefile
src/lib/python/isc/cc/Makefile
src/lib/python/isc/cc/tests/Makefile
src/lib/python/isc/config/Makefile
......
SUBDIRS = . tests
python_PYTHON = __init__.py master.py sqlite3_ds.py
pythondir = $(pyexecdir)/isc/datasrc
......@@ -103,7 +103,7 @@ def isname(s):
# isttl: check whether a string is a valid TTL specifier.
# returns: boolean
#########################################################################
ttl_regex = re.compile('([0-9]+[wdhms]?)+', re.I)
ttl_regex = re.compile('([0-9]+[wdhms]?)+$', re.I)
def isttl(s):
global ttl_regex
if ttl_regex.match(s):
......
PYTESTS = master_test.py
EXTRA_DIST = $(PYTESTS)
# later will have configure option to choose this, like: coverage run --branch
PYCOVERAGE = $(PYTHON)
# test using command-line arguments, so use check-local target instead of TESTS
check-local:
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/lib/python/isc/log \
$(PYCOVERAGE) $(abs_srcdir)/$$pytest || exit ; \
done
# Copyright (C) 2010 Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
from isc.datasrc.master import *
import unittest
class TestTTL(unittest.TestCase):
def test_ttl(self):
self.assertTrue(isttl('3600'))
self.assertTrue(isttl('1W'))
self.assertTrue(isttl('1w'))
self.assertTrue(isttl('2D'))
self.assertTrue(isttl('2d'))
self.assertTrue(isttl('30M'))
self.assertTrue(isttl('30m'))
self.assertTrue(isttl('10S'))
self.assertTrue(isttl('10s'))
self.assertTrue(isttl('2W1D'))
self.assertFalse(isttl('not a ttl'))
self.assertFalse(isttl('1X'))
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment