File: result_table_test.py

package info (click to toggle)
dupeguru 4.3.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,604 kB
  • sloc: python: 16,846; ansic: 424; makefile: 123
file content (61 lines) | stat: -rw-r--r-- 2,229 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Created By: Virgil Dupras
# Created On: 2013-07-28
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html

from core.tests.base import TestApp, GetTestGroups


def app_with_results():
    app = TestApp()
    objects, matches, groups = GetTestGroups()
    app.app.results.groups = groups
    app.rtable.refresh()
    return app


def test_delta_flags_delta_mode_off():
    app = app_with_results()
    # When the delta mode is off, we never have delta values flags
    app.rtable.delta_values = False
    # Ref file, always false anyway
    assert not app.rtable[0].is_cell_delta("size")
    # False because delta mode is off
    assert not app.rtable[1].is_cell_delta("size")


def test_delta_flags_delta_mode_on_delta_columns():
    # When the delta mode is on, delta columns always have a delta flag, except for ref rows
    app = app_with_results()
    app.rtable.delta_values = True
    # Ref file, always false anyway
    assert not app.rtable[0].is_cell_delta("size")
    # But for a dupe, the flag is on
    assert app.rtable[1].is_cell_delta("size")


def test_delta_flags_delta_mode_on_non_delta_columns():
    # When the delta mode is on, non-delta columns have a delta flag if their value differs from
    # their ref.
    app = app_with_results()
    app.rtable.delta_values = True
    # "bar bleh" != "foo bar", flag on
    assert app.rtable[1].is_cell_delta("name")
    # "ibabtu" row, but it's a ref, flag off
    assert not app.rtable[3].is_cell_delta("name")
    # "ibabtu" == "ibabtu", flag off
    assert not app.rtable[4].is_cell_delta("name")


def test_delta_flags_delta_mode_on_non_delta_columns_case_insensitive():
    # Comparison that occurs for non-numeric columns to check whether they're delta is case
    # insensitive
    app = app_with_results()
    app.app.results.groups[1].ref.name = "ibAbtu"
    app.app.results.groups[1].dupes[0].name = "IBaBTU"
    app.rtable.delta_values = True
    # "ibAbtu" == "IBaBTU", flag off
    assert not app.rtable[4].is_cell_delta("name")