diff options
author | Rob Austein <sra@hactrn.net> | 2008-05-16 03:10:53 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2008-05-16 03:10:53 +0000 |
commit | 7a5062ef3577ae21cd0794aa686b089260bf19ba (patch) | |
tree | 5dcd82ab63d1dd0e3dae076f1357267532a24506 | |
parent | 10c6004df383b32c76876c1c48c575ae9b9b98dd (diff) |
Fix .union() bug found by unit tests, clean up.
svn path=/rpkid/Makefile; revision=1781
-rw-r--r-- | rpkid/Makefile | 2 | ||||
-rw-r--r-- | rpkid/rpki/resource_set.py | 4 | ||||
-rw-r--r-- | rpkid/rpki/sundial.py | 31 |
3 files changed, 17 insertions, 20 deletions
diff --git a/rpkid/Makefile b/rpkid/Makefile index a561c44e..7f7cbb9d 100644 --- a/rpkid/Makefile +++ b/rpkid/Makefile @@ -35,7 +35,7 @@ relaxng: left-right-protocol-samples/.stamp left-right-schema.rng up-down-schema xmllint --noout --relaxng up-down-schema.rng up-down-protocol-samples/*.xml unit-tests: all - PWD=`pwd`; for i in rpki/*.py; do PYTHONPATH=$$PWD python $$i; done + PWD=`pwd`; for i in rpki/*.py; do echo "[$$i]"; PYTHONPATH=$$PWD python $$i; done all-tests:: unit-tests diff --git a/rpkid/rpki/resource_set.py b/rpkid/rpki/resource_set.py index 9b708543..0e096662 100644 --- a/rpkid/rpki/resource_set.py +++ b/rpkid/rpki/resource_set.py @@ -241,7 +241,7 @@ class resource_set(list): result.append(type(this)(min, max)) for i in range(len(result) - 2, -1, -1): if result[i].max + 1 == result[i + 1].min: - result[i].max = result[i + 1].max + result[i] = type(result[i])(result[i].min, result[i+1].max) result.pop(i + 1) return type(self)(result) @@ -585,8 +585,10 @@ if __name__ == "__main__": assert v1 == v2 print "x&y:", v1 + print print "Testing set operations on resource sets" test(resource_set_as, "1,2,3,4,5,6,11,12,13,14,15", "1,2,3,4,5,6,111,121,131,141,151") test(resource_set_ipv4, "10.0.0.44/32,10.6.0.2/32", "10.3.0.0/24,10.0.0.77/32") test(resource_set_ipv4, "10.0.0.44/32,10.6.0.2/32", "10.0.0.0/24") test(resource_set_ipv4, "10.0.0.0/24", "10.3.0.0/24,10.0.0.77/32") + print diff --git a/rpkid/rpki/sundial.py b/rpkid/rpki/sundial.py index 69f98f24..a50498c2 100644 --- a/rpkid/rpki/sundial.py +++ b/rpkid/rpki/sundial.py @@ -171,23 +171,18 @@ class timedelta(pydatetime.timedelta): if __name__ == "__main__": - now = datetime.now() - print now - print repr(now) - print now.strftime("%s") - print now.toUTCTime() - print now.toGeneralizedTime() - print now.toASN1tuple() - print now.toXMLtime() + def test(t): + print + print "str: ", t + print "repr: ", repr(t) + print "seconds since epoch:", t.strftime("%s") + print "UTCTime: ", t.toUTCTime() + print "GeneralizedTime: ", t.toGeneralizedTime() + print "ASN1tuple: ", t.toASN1tuple() + print "XMLtime: ", t.toXMLtime() + print print - - then = now - then += timedelta(days = 30) - print then - print repr(then) - print then.strftime("%s") - print then.toUTCTime() - print then.toGeneralizedTime() - print then.toASN1tuple() - print then.toXMLtime() + print "Testing time conversion routines" + test(now()) + test(now() + timedelta(days = 30)) |