diff options
author | Rod Smith <rod.smith@canonical.com> | 2022-04-06 13:02:22 -0400 |
---|---|---|
committer | Rod Smith <rod.smith@canonical.com> | 2022-04-06 13:02:22 -0400 |
commit | ef896de0752843ccc65ba9e9fc6948e6fa2083a9 (patch) | |
tree | f9dff59599a83dde89f6a49f43503bdc4945fdcf | |
parent | 513b7993ac8efcb356821da85fec295b0da70eab (diff) |
Add: unit test for python3-natsort library
-rw-r--r-- | tests/test_natsort.py | 42 |
1 files changed, 42 insertions, 0 deletions
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) |