diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:46:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:46:09 +0000 |
commit | 043aa641ad4373e96fd748deb1e7fab3cb579a07 (patch) | |
tree | f8fde8a97ab5db152043f6c01043672114c0a4df /python/tests | |
parent | Releasing progress-linux version 2.1.6-5~progress7.99u1. (diff) | |
download | pacemaker-043aa641ad4373e96fd748deb1e7fab3cb579a07.tar.xz pacemaker-043aa641ad4373e96fd748deb1e7fab3cb579a07.zip |
Merging upstream version 2.1.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | python/tests/Makefile.am | 3 | ||||
-rw-r--r-- | python/tests/__init__.py | 0 | ||||
-rw-r--r-- | python/tests/test_cts_network.py | 37 |
3 files changed, 39 insertions, 1 deletions
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am index 490b272..219812c 100644 --- a/python/tests/Makefile.am +++ b/python/tests/Makefile.am @@ -9,4 +9,5 @@ MAINTAINERCLEANFILES = Makefile.in -EXTRA_DIST = $(wildcard test_*) +EXTRA_DIST = $(wildcard test_*) \ + __init__.py diff --git a/python/tests/__init__.py b/python/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/python/tests/__init__.py diff --git a/python/tests/test_cts_network.py b/python/tests/test_cts_network.py new file mode 100644 index 0000000..4aea8b9 --- /dev/null +++ b/python/tests/test_cts_network.py @@ -0,0 +1,37 @@ +# These warnings are not useful in unit tests. +# pylint: disable=missing-class-docstring,missing-function-docstring,missing-module-docstring + +__copyright__ = "Copyright 2023 the Pacemaker project contributors" +__license__ = "GPLv2+" + +import unittest + +from pacemaker._cts.network import next_ip + +# next_ip makes a bunch of assumptions that we are not going to test here: +# +# * The env argument actually contains an "IPBase" key with a string in it +# * The string is a properly formatted IPv4 or IPv6 address, with no extra +# leading or trailing whitespace + +class NextIPTestCase(unittest.TestCase): + def test_ipv4(self): + # The first time next_ip is called, it will read the IPBase out of + # the environment. After that, it just goes off whatever it + # previously returned, so the environment value doesn't matter. + self.assertEqual(next_ip("1.1.1.1"), "1.1.1.2") + self.assertEqual(next_ip(), "1.1.1.3") + + # Passing reset=True will force it to re-read the environment. Here, + # we use that to ask it for a value outside of the available range. + self.assertRaises(ValueError, next_ip, "1.1.1.255", reset=True) + + def test_ipv6(self): + # Same comments as for the test_ipv4 function, plus we need to reset + # here because otherwise it will remember what happened in that function. + self.assertEqual(next_ip("fe80::fc54:ff:fe09:101", reset=True), + "fe80::fc54:ff:fe09:102") + self.assertEqual(next_ip(), + "fe80::fc54:ff:fe09:103") + + self.assertRaises(ValueError, next_ip, "fe80::fc54:ff:fe09:ffff", reset=True) |