@@ -173,6 +173,70 @@ def test_get_comparisionexes_branch_filtering(self):
173173 for index , exe_key in enumerate (expected_exe_keys ):
174174 self .assertEqual (executables [self .project ][index ]['key' ], exe_key )
175175
176+ def test_get_comparisionexes_tag_name_filtering (self ):
177+ # Insert some mock revisions with tags
178+ rev_v4 = Revision .objects .create (
179+ branch = self .branch_master , commitid = '4' , tag = 'v4.0.0' )
180+ rev_v5 = Revision .objects .create (
181+ branch = self .branch_master , commitid = '5' , tag = 'v5.0.0' )
182+ rev_v6 = Revision .objects .create (
183+ branch = self .branch_master , commitid = '6' , tag = 'v6.0.0' )
184+
185+ # No COMPARIION_TAGS filters specified, all the tags should be included
186+ executables , exe_keys = getcomparisonexes ()
187+ self .assertEqual (len (executables ), 1 )
188+ self .assertEqual (len (executables [self .project ]), 2 * 2 + 2 * 3 )
189+ self .assertEqual (len (exe_keys ), 2 * 2 + 2 * 3 )
190+
191+ self .assertExecutablesListContainsRevision (executables [self .project ], rev_v4 )
192+ self .assertExecutablesListContainsRevision (executables [self .project ], rev_v5 )
193+ self .assertExecutablesListContainsRevision (executables [self .project ], rev_v6 )
194+
195+ # Only a single tag should be included
196+ with override_settings (COMPARISON_TAGS = ['v4.0.0' ]):
197+ executables , exe_keys = getcomparisonexes ()
198+ self .assertEqual (len (executables ), 1 )
199+ self .assertEqual (len (executables [self .project ]), 2 * 2 + 2 * 1 )
200+ self .assertEqual (len (exe_keys ), 2 * 2 + 2 * 1 )
201+
202+ self .assertExecutablesListContainsRevision (executables [self .project ], rev_v4 )
203+ self .assertExecutablesListDoesntContainRevision (executables [self .project ], rev_v5 )
204+ self .assertExecutablesListDoesntContainRevision (executables [self .project ], rev_v6 )
205+
206+ # No tags should be included
207+ with override_settings (COMPARISON_TAGS = []):
208+ executables , exe_keys = getcomparisonexes ()
209+ self .assertEqual (len (executables ), 1 )
210+ self .assertEqual (len (executables [self .project ]), 2 * 2 )
211+ self .assertEqual (len (exe_keys ), 2 * 2 )
212+
213+ self .assertExecutablesListDoesntContainRevision (executables [self .project ], rev_v4 )
214+ self .assertExecutablesListDoesntContainRevision (executables [self .project ], rev_v5 )
215+ self .assertExecutablesListDoesntContainRevision (executables [self .project ], rev_v6 )
216+
217+ def assertExecutablesListContainsRevision (self , executables , revision ):
218+ found = self ._executable_list_contains_revision (executables = executables ,
219+ revision = revision )
220+
221+ if not found :
222+ self .assertFalse ("Didn't find revision \" %s\" in executable list \" %s\" " %
223+ (str (revision ), str (executables )))
224+
225+ def assertExecutablesListDoesntContainRevision (self , executables , revision ):
226+ found = self ._executable_list_contains_revision (executables = executables ,
227+ revision = revision )
228+
229+ if found :
230+ self .assertFalse ("Found revision \" %s\" , but didn't expect it" %
231+ (str (revision )))
232+
233+ def _executable_list_contains_revision (self , executables , revision ):
234+ for executable in executables :
235+ if executable ['revision' ] == revision :
236+ return True
237+
238+ return False
239+
176240
177241class UtilityFunctionsTestCase (TestCase ):
178242 @override_settings (TIMELINE_EXECUTABLE_NAME_MAX_LEN = 22 )
0 commit comments