1 """Tests DAG functionality"""
2 # pylint: disable=redefined-outer-name
3 from __future__
import absolute_import
, division
, print_function
, unicode_literals
7 from cola
.models
import dag
9 from .helper
import app_context
10 from .helper
import patch
13 assert app_context
is not None
17 ad454b189fe5785af397fd6067cf103268b6626e^A^A (tag: refs/tags/v0.0)^ADavid Aguilar^AFri Nov 30 00:03:28 2007 -0800^Adavvid@gmail.com^Afirst cut of ugit
18 1ba04ad185cf9f04c56c8482e9a73ef1bd35c695^Aad454b189fe5785af397fd6067cf103268b6626e^A^ADavid Aguilar^AFri Nov 30 05:07:47 2007 -0800^Adavvid@gmail.com^Aupdated model/view/controller api
19 fa5ad6c38be603e2ffd1f9b722a3a5c675f63de2^A1ba04ad185cf9f04c56c8482e9a73ef1bd35c695^A^ADavid Aguilar^AFri Nov 30 05:19:05 2007 -0800^Adavvid@gmail.com^AAvoid multiple signoffs
20 103766573cd4e6799d3ee792bcd632b92cf7c6c0^Afa5ad6c38be603e2ffd1f9b722a3a5c675f63de2^A^ADavid Aguilar^ATue Dec 11 05:13:21 2007 -0800^Adavvid@gmail.com^AAdded TODO
21 e3f5a2d0248de6197d6e0e63c901810b8a9af2f8^Afa5ad6c38be603e2ffd1f9b722a3a5c675f63de2^A^ADavid Aguilar^AMon Dec 3 02:36:06 2007 -0800^Adavvid@gmail.com^AMerged qlistwidgets into main.
22 f4fb8fd5baaa55d9b41faca79be289bb4407281e^Ae3f5a2d0248de6197d6e0e63c901810b8a9af2f8^A^ADavid Aguilar^ATue Dec 4 03:14:56 2007 -0800^Adavvid@gmail.com^ASquashed commit of the following:
23 23e7eab4ba2c94e3155f5d261c693ccac1342eb9^Af4fb8fd5baaa55d9b41faca79be289bb4407281e^A^ADavid Aguilar^AThu Dec 6 18:59:20 2007 -0800^Adavvid@gmail.com^AMerged diffdisplay into main
24 """.strip().replace( # noqa
33 class DAGTestData(object):
34 """Test data provided by the dag_context fixture"""
35 def __init__(self
, app_context
, head
='HEAD', count
=1000):
36 self
.context
= app_context
37 self
.params
= dag
.DAG(head
, count
)
38 self
.reader
= dag
.RepoReader(app_context
, self
.params
)
42 def dag_context(app_context
):
43 """Provide DAGTestData for use by tests"""
44 return DAGTestData(app_context
)
47 @patch('cola.models.dag.core')
48 def test_repo_reader(core
, dag_context
):
49 expect
= len(LOG_LINES
) - 1
52 core
.readline
.return_value
= LOG_LINES
[0]
53 for idx
, _
in enumerate(dag_context
.reader
.get()):
54 core
.readline
.return_value
= LOG_LINES
[idx
+ 1]
57 assert expect
== actual
60 @patch('cola.models.dag.core')
61 def test_repo_reader_order(core
, dag_context
):
63 'ad454b189fe5785af397fd6067cf103268b6626e',
64 '1ba04ad185cf9f04c56c8482e9a73ef1bd35c695',
65 'fa5ad6c38be603e2ffd1f9b722a3a5c675f63de2',
66 '103766573cd4e6799d3ee792bcd632b92cf7c6c0',
67 'e3f5a2d0248de6197d6e0e63c901810b8a9af2f8',
68 'f4fb8fd5baaa55d9b41faca79be289bb4407281e',
69 '23e7eab4ba2c94e3155f5d261c693ccac1342eb9',
71 core
.readline
.return_value
= LOG_LINES
[0]
72 for idx
, commit
in enumerate(dag_context
.reader
.get()):
73 assert commits
[idx
] == commit
.oid
74 core
.readline
.return_value
= LOG_LINES
[idx
+ 1]
77 @patch('cola.models.dag.core')
78 def test_repo_reader_parents(core
, dag_context
):
81 ['ad454b189fe5785af397fd6067cf103268b6626e'],
82 ['1ba04ad185cf9f04c56c8482e9a73ef1bd35c695'],
83 ['fa5ad6c38be603e2ffd1f9b722a3a5c675f63de2'],
84 ['fa5ad6c38be603e2ffd1f9b722a3a5c675f63de2'],
85 ['e3f5a2d0248de6197d6e0e63c901810b8a9af2f8'],
86 ['f4fb8fd5baaa55d9b41faca79be289bb4407281e'],
88 core
.readline
.return_value
= LOG_LINES
[0]
89 for idx
, commit
in enumerate(dag_context
.reader
.get()):
90 assert parents
[idx
] == [p
.oid
for p
in commit
.parents
]
91 core
.readline
.return_value
= LOG_LINES
[idx
+ 1]
94 @patch('cola.models.dag.core')
95 def test_repo_reader_contract(core
, dag_context
):
96 core
.exists
.return_value
= True
97 core
.readline
.return_value
= LOG_LINES
[0]
99 for idx
, _
in enumerate(dag_context
.reader
.get()):
100 core
.readline
.return_value
= LOG_LINES
[idx
+ 1]
102 core
.start_command
.assert_called()
103 call_args
= core
.start_command
.call_args
105 assert 'log.abbrevCommit=false' in call_args
[0][0]
106 assert 'log.showSignature=false' in call_args
[0][0]