@@ -141,6 +141,38 @@ def test_get_comparisionexes_custom_default_branch(self):
141141 self .assertEqual (exe_keys [2 ], '1+L+custom' )
142142 self .assertEqual (exe_keys [3 ], '2+L+custom' )
143143
144+ def test_get_comparisionexes_branch_filtering (self ):
145+ # branch1 and branch3 have display_on_comparison_page flag set to False
146+ # so they shouldn't be included in the result
147+ branch1 = Branch .objects .create (name = 'branch1' , project = self .project ,
148+ display_on_comparison_page = False )
149+ branch2 = Branch .objects .create (name = 'branch2' , project = self .project ,
150+ display_on_comparison_page = True )
151+ branch3 = Branch .objects .create (name = 'branch3' , project = self .project ,
152+ display_on_comparison_page = False )
153+
154+ Revision .objects .create (branch = branch1 , commitid = '1' )
155+ Revision .objects .create (branch = branch2 , commitid = '1' )
156+ Revision .objects .create (branch = branch3 , commitid = '1' )
157+
158+ executables , exe_keys = getcomparisonexes ()
159+ self .assertEqual (len (executables ), 1 )
160+ self .assertEqual (len (executables [self .project ]), 6 )
161+ self .assertEqual (len (exe_keys ), 6 )
162+
163+ expected_exe_keys = [
164+ '1+L+master' ,
165+ '2+L+master' ,
166+ '1+L+custom' ,
167+ '2+L+custom' ,
168+ '1+L+branch2' ,
169+ '2+L+branch2'
170+ ]
171+ self .assertEqual (exe_keys , expected_exe_keys )
172+
173+ for index , exe_key in enumerate (expected_exe_keys ):
174+ self .assertEqual (executables [self .project ][index ]['key' ], exe_key )
175+
144176
145177class UtilityFunctionsTestCase (TestCase ):
146178 @override_settings (TIMELINE_EXECUTABLE_NAME_MAX_LEN = 22 )
0 commit comments