def test_add_index_sort():
    lst = [{'value': 1, 'idx': 1},
           {'value': 0},
           {'value': 2}]

    add_index(lst, 'idx')
    add_index_check(lst)
def test_add_index_idx_out_of_range():
    lst = add_index_setup()
    lst[0]['idx'] = 4

    with assert_raises(ValueError) as cm:
        add_index(lst, 'idx')
    assert str(cm.exception) == "Some index value are out-of-range: [4]"
示例#3
0
    def test_add_index_sort(self):  # pylint: disable=no-self-use
        lst = [{'value': 1, 'idx': 1},
               {'value': 0},
               {'value': 2}]

        add_index(lst, 'idx')
        self.add_index_check(lst)
def test_add_index_some_exist():
    lst = add_index_setup()
    lst[1]['idx'] = 1

    add_index(lst, 'idx')

    add_index_check(lst)
示例#5
0
    def test_add_index_idx_out_of_range(self):
        lst = add_index_setup()
        lst[0]['idx'] = 4

        with self.assertRaises(ValueError) as context:
            add_index(lst, 'idx')
        self.assertEqual(str(context.exception), "Some index value are out-of-range: [4]")
def test_add_index_idx_duplicate():
    lst = add_index_setup()
    lst[0]['idx'] = 1
    lst[1]['idx'] = 1

    with assert_raises(ValueError) as cm:
        add_index(lst, 'idx')
    assert str(cm.exception) == "Duplicates found in list: [(1, 2)]"
def test_add_index_idx_is_none():
    lst = add_index_setup()
    for d in lst:
        d['idx'] = None

    add_index(lst, 'idx')

    add_index_check(lst)
示例#8
0
    def test_add_index_idx_is_none(self):
        lst = add_index_setup()
        for test_dict in lst:
            test_dict['idx'] = None

        add_index(lst, 'idx')

        self.add_index_check(lst)
示例#9
0
    def test_add_index_idx_duplicate(self):
        lst = add_index_setup()
        lst[0]['idx'] = 1
        lst[1]['idx'] = 1

        with self.assertRaises(ValueError) as context:
            add_index(lst, 'idx')
        self.assertEqual(str(context.exception), "Duplicates found in list: [(1, 2)]")
示例#10
0
def test_add_index_no_exist():
    lst = add_index_setup()

    add_index(lst, 'idx')

    add_index_check(lst)