aboutsummaryrefslogtreecommitdiff
path: root/gn2/tests/wqflask/show_trait/testSampleList.py
blob: 1c5478bbeeaf5a9eb57ed48099726bf98cf1bf2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import unittest
import re
from unittest import mock
from gn2.wqflask.show_trait.SampleList import natural_sort


class TestSampleList(unittest.TestCase):
    def test_natural_sort(self):
        "Sort the list into natural alphanumeric order."

        characters_list = ["z", "f", "q", "s", "t", "a", "g"]
        names_list = ["temp1", "publish", "Sample", "Dataset"]
        sorted_list_a = natural_sort(characters_list)
        sorted_list_b = natural_sort(names_list)
        self.assertEqual(sorted_list_a, ["a", "f", "g", "q", "s", "t", "z"])
        self.assertEqual(
            sorted_list_b, ["Dataset", "Sample", "publish", "temp1"])