summaryrefslogtreecommitdiff
diff options
authorUbuntu <ubuntu@cert-jenkins-slave-1-201406-15260.maas>2022-04-07 14:35:26 +0000
committerUbuntu <ubuntu@cert-jenkins-slave-1-201406-15260.maas>2022-04-07 14:35:26 +0000
commit6e813923e66585025c6411b5ccbf6232cf51a17a (patch)
treeefe7f391e2374e28a2c1a02b1f0fa7e7dc832611
parent1ec661799c74fd0c56d08dd70d2846abea2878e3 (diff)
parent58d4f457ee1897af5137a39281bc835f1a64a005 (diff)
Merge #418752 from ~rodsmith/plainbox-provider-checkbox:add-natsort-unit-test
Add: unit test for python3-natsort library
-rw-r--r--requirements/deb-base.txt1
-rw-r--r--tests/test_natsort.py42
2 files changed, 43 insertions, 0 deletions
diff --git a/requirements/deb-base.txt b/requirements/deb-base.txt
index 895f3a2..48b8b1e 100644
--- a/requirements/deb-base.txt
+++ b/requirements/deb-base.txt
@@ -1,4 +1,5 @@
python3-jinja2
+python3-natsort
python3-padme
python3-urwid
python3-xlsxwriter
diff --git a/tests/test_natsort.py b/tests/test_natsort.py
new file mode 100644
index 0000000..15418b8
--- /dev/null
+++ b/tests/test_natsort.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+# encoding: utf-8
+# Copyright 2022 Canonical Ltd.
+# Written by:
+# Rod Smith <rod.smith@canonical.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3,
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from natsort import natsorted
+import unittest
+
+
+class TestSortingOfNetworkSpeeds(unittest.TestCase):
+
+ def test_sortspeeds(self):
+ # Input taken from cloaker's ens1f0, a Mellanox ConnectX-5 Ex
+ input = ['1000baseKX/Full', '10000baseKR/Full', '40000baseKR4/Full',
+ '40000baseCR4/Full', '40000baseSR4/Full',
+ '40000baseLR4/Full', '25000baseCR/Full', '25000baseKR/Full',
+ '25000baseSR/Full', '50000baseCR2/Full', '50000baseKR2/Full',
+ '100000baseKR4/Full', '100000baseSR4/Full',
+ '100000baseCR4/Full', '100000baseLR4_ER4/Full']
+ expected_output = ['1000baseKX/Full', '10000baseKR/Full',
+ '25000baseCR/Full', '25000baseKR/Full',
+ '25000baseSR/Full', '40000baseCR4/Full',
+ '40000baseKR4/Full', '40000baseLR4/Full',
+ '40000baseSR4/Full', '50000baseCR2/Full',
+ '50000baseKR2/Full', '100000baseCR4/Full',
+ '100000baseKR4/Full', '100000baseLR4_ER4/Full',
+ '100000baseSR4/Full']
+ output = natsorted(input)
+ self.assertEqual(expected_output, output)