Ejemplo n.º 1
0
 def test_get_indices_no_items_to_search(self):
     """_get_indices() should return an empty list if no search items are
     given."""
     item_to_find = []
     self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find), [])
     item_to_find = ""
     self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find), [])
     item_to_find = None
     self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find), [])
Ejemplo n.º 2
0
    def test_get_indices_null_or_empty_search_list(self):
        """_get_indices() should throw an error if the search list is None, and
        return an empty list if the search list is empty."""
        search_list = None
        self.assertRaises(ValueError, _get_indices, search_list, "item")

        search_list = []
        self.assertEqual(_get_indices(search_list, "item"), [])

        search_list = ""
        self.assertEqual(_get_indices(search_list, "item"), [])
Ejemplo n.º 3
0
    def test_get_indices_null_or_empty_search_list(self):
        """_get_indices() should throw an error if the search list is None, and
        return an empty list if the search list is empty."""
        search_list = None
        self.assertRaises(ValueError, _get_indices, search_list, 'item')

        search_list = []
        self.assertEqual(_get_indices(search_list, 'item'), [])

        search_list = ''
        self.assertEqual(_get_indices(search_list, 'item'), [])
Ejemplo n.º 4
0
    def test_get_indices_no_existing_item(self):
        """_get_indices() should return an empty list if no items exist in the
        search list."""
        item_to_find = "PC.4242"
        self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find), [])
        item_to_find = 42
        self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find), [])
        item_to_find = ["PC.4242", "CP.2424"]
        self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find), [])

        item_to_find = ["PC.4242", "CP.2424", 56]
        self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find), [])
Ejemplo n.º 5
0
 def test_get_indices_no_items_to_search(self):
     """_get_indices() should return an empty list if no search items are
     given."""
     item_to_find = []
     self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find),
                      [])
     item_to_find = ''
     self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find),
                      [])
     item_to_find = None
     self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find),
                      [])
Ejemplo n.º 6
0
    def test_get_indices_several_existing_items(self):
        """_get_indices() should return a list of valid indices for several
        existing items."""
        control_ids = ["PC.354", "PC.355", "PC.356", "PC.481", "PC.593"]
        exp_control_indices = [0, 1, 2, 3, 4]

        fast_ids = ["PC.607", "PC.634", "PC.635", "PC.636"]
        exp_fast_indices = [5, 6, 7, 8]

        obs_control = _get_indices(self.dist_matrix_header, control_ids)
        self.assertEqual(obs_control, exp_control_indices)

        obs_fast = _get_indices(self.dist_matrix_header, fast_ids)
        self.assertEqual(obs_fast, exp_fast_indices)
Ejemplo n.º 7
0
    def test_get_indices_several_existing_items(self):
        """_get_indices() should return a list of valid indices for several
        existing items."""
        control_ids = ['PC.354', 'PC.355', 'PC.356', 'PC.481', 'PC.593']
        exp_control_indices = [0, 1, 2, 3, 4]

        fast_ids = ['PC.607', 'PC.634', 'PC.635', 'PC.636']
        exp_fast_indices = [5, 6, 7, 8]

        obs_control = _get_indices(self.dist_matrix_header, control_ids)
        self.assertEqual(obs_control, exp_control_indices)

        obs_fast = _get_indices(self.dist_matrix_header, fast_ids)
        self.assertEqual(obs_fast, exp_fast_indices)
Ejemplo n.º 8
0
    def test_get_indices_no_existing_item(self):
        """_get_indices() should return an empty list if no items exist in the
        search list."""
        item_to_find = 'PC.4242'
        self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find),
                         [])
        item_to_find = 42
        self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find),
                         [])
        item_to_find = ['PC.4242', 'CP.2424']
        self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find),
                         [])

        item_to_find = ['PC.4242', 'CP.2424', 56]
        self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find),
                         [])
Ejemplo n.º 9
0
 def test_get_indices_one_existing_item_scalar(self):
     """_get_indices() should return a list of size 1 for a single item that
     exists in the search list."""
     item_to_find = "PC.355"
     self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find), [1])
Ejemplo n.º 10
0
 def test_get_indices_one_existing_item_scalar(self):
     """_get_indices() should return a list of size 1 for a single item that
     exists in the search list."""
     item_to_find = 'PC.355'
     self.assertEqual(_get_indices(self.dist_matrix_header, item_to_find),
                      [1])