예제 #1
0
 def test_combine(self):
     # This is more like an acceptance test than a unit test ...
     for comb_tags, tests_tags, crit_tags in [
             (['t1&t2'], [['t1','t2','t3'],['t1','t3']], []),
             (['1&2&3'], [['1','2','3'],['1','2','3','4']], ['1','2']),
             (['1&2','1&3'], [['1','2','3'],['1','3'],['1']], ['1']),
             (['t*'], [['t1','x','y'],['tee','z'],['t']], ['x']),
             (['t?&s'], [['t1','s'],['tt','s','u'],['tee','s'],['s']], []),
             (['t*&s','*'], [['s','t','u'],['tee','s'],[],['x']], []),
             (['tNOTs'], [['t','u'],['t','s']], []),
             (['tNOTs','t&s','tNOTsNOTu', 't&sNOTu'],
               [['t','u'],['t','s'],['s','t','u'],['t'],['t','v']], ['t']),
             (['nonex'], [['t1'],['t1,t2'],[]], [])
            ]:
         # 1) Create tag stats
         builder = TagStatisticsBuilder(Criticality(crit_tags),
                                        combined=[(t, '') for t in comb_tags])
         all_tags = []
         for tags in tests_tags:
             builder.add_test(TestCase(status='PASS', tags=tags),)
             all_tags.extend(tags)
         # 2) Actual values
         names = [stat.name for stat in builder.stats]
         # 3) Expected values
         exp_crit = []; exp_noncr = []
         for tag in utils.normalize_tags(all_tags):
             if tag in crit_tags:
                 exp_crit.append(tag)
             else:
                 exp_noncr.append(tag)
         exp_names = exp_crit + sorted(comb_tags) + exp_noncr
         # 4) Verify names (match counts were already verified)
         assert_equals(names, exp_names)
예제 #2
0
 def _convert_test(self, test):
     return {
         'name': test.name,
         'fullName': test.longname,
         'id': test.id,
         'doc': self._html(test.doc),
         'tags': utils.normalize_tags(test.tags),
         'timeout': self._get_timeout(test.timeout),
         'keywords': list(self._convert_keywords(test))
     }
예제 #3
0
 def _convert_test(self, test):
     return {
         'name': test.name,
         'fullName': test.longname,
         'id': test.id,
         'doc': self._html(test.doc),
         'tags': utils.normalize_tags(test.tags),
         'timeout': self._get_timeout(test.timeout),
         'keywords': list(self._convert_keywords(test))
     }
예제 #4
0
 def test_combine(self):
     # This test is more like an acceptance test than a unit test and
     # is doing too much...
     for comb_tags, comb_matches, tests_tags, crit_tags in [
         (['t1&t2'], [1], [['t1', 't2', 't3'], ['t1', 't3']], []),
         (['1&2&3'], [2], [['1', '2', '3'], ['1', '2', '3',
                                             '4']], ['1', '2']),
         (['1&2', '1&3'], [1, 2], [['1', '2', '3'], ['1', '3'],
                                   ['1']], ['1']),
         (['t*'], [3], [['t1', 'x', 'y'], ['tee', 'z'], ['t']], ['x']),
         (['t?&s'], [2], [['t1', 's'], ['tt', 's', 'u'], ['tee', 's'],
                          ['s']], []),
         (['t*&s', '*'], [2, 3], [['s', 't', 'u'], ['tee', 's'], [],
                                  ['x']], []),
         (['tNOTs'], [1], [['t', 'u'], ['t', 's']], []),
         (['tNOTs', 't&s',
           'tNOTsNOTu', 't&sNOTu'], [3, 2, 2, 1], [['t', 'u'], ['t', 's'],
                                                   ['s', 't', 'u'], ['t'],
                                                   ['t', 'v']], ['t']),
         (['nonex'], [0], [['t1'], ['t1,t2'], []], [])
     ]:
         # 1) Create tag stats
         tagstats = TagStatistics([], [], comb_tags)
         all_tags = []
         for tags in tests_tags:
             tagstats.add_test(TestMock('PASS', tags), _Critical(crit_tags))
             all_tags.extend(tags)
         # 2) Actual values
         stats = tagstats.stats.values()
         stats.sort()  # sorts crit first, then comb, then non-crit
         names = [stat.name for stat in stats]
         # 3) Expected values
         exp_crit = []
         exp_noncr = []
         exp_comb = []
         for tag in utils.normalize_tags(all_tags):
             if tag in crit_tags:
                 exp_crit.append(tag)
             else:
                 exp_noncr.append(tag)
         for comb, count in zip(comb_tags, comb_matches):
             name = comb.replace('&', ' & ').replace('NOT', ' NOT ')
             exp_comb.append(name)
             try:
                 assert_equals(len(tagstats.stats[name].tests), count)
             except KeyError:
                 fail("No key %s. Stats: %s" % (name, tagstats.stats))
         exp_comb.sort()
         exp_names = exp_crit + exp_comb + exp_noncr
         # 4) Verify names (match counts were already verified)
         assert_equals(names, exp_names)
예제 #5
0
파일: model.py 프로젝트: nbbull/RIDE
 def _init_test(self, context):
     errors = []
     self.doc = context.replace_vars_from_setting("Documentation", self.doc, errors)
     self.setup.replace_variables(context.get_current_vars(), errors)
     self.teardown.replace_variables(context.get_current_vars(), errors)
     tags = context.replace_vars_from_setting("Tags", self.tags, errors)
     self.tags = utils.normalize_tags(tags)
     self.timeout.replace_variables(context.get_current_vars())
     if errors:
         return "Test case initialization failed:\n%s" % "\n".join(errors)
     if not self.name:
         return "Test case name is required."
     if not self.keywords:
         return "Test case contains no keywords"
     return None
예제 #6
0
 def _init_test(self, context):
     errors = []
     self.doc = context.replace_vars_from_setting('Documentation', self.doc,
                                                  errors)
     self.setup.replace_variables(context.get_current_vars(), errors)
     self.teardown.replace_variables(context.get_current_vars(), errors)
     tags = context.replace_vars_from_setting('Tags', self.tags, errors)
     self.tags = utils.normalize_tags(tags)
     self.timeout.replace_variables(context.get_current_vars())
     if errors:
         return 'Test case initialization failed:\n%s' % '\n'.join(errors)
     if not self.name:
         return 'Test case name is required.'
     if not self.keywords:
         return 'Test case contains no keywords'
     return None
예제 #7
0
 def test_combine(self):
     # This is more like an acceptance test than a unit test ...
     for comb_tags, tests_tags, crit_tags in [
         (['t1&t2'], [['t1', 't2', 't3'], ['t1', 't3']], []),
         (['1&2&3'], [['1', '2', '3'], ['1', '2', '3', '4']], ['1', '2']),
         (['1&2', '1&3'], [['1', '2', '3'], ['1', '3'], ['1']], ['1']),
         (['t*'], [['t1', 'x', 'y'], ['tee', 'z'], ['t']], ['x']),
         (['t?&s'], [['t1', 's'], ['tt', 's', 'u'], ['tee', 's'],
                     ['s']], []),
         (['t*&s', '*'], [['s', 't', 'u'], ['tee', 's'], [], ['x']], []),
         (['tNOTs'], [['t', 'u'], ['t', 's']], []),
         (['tNOTs', 't&s', 'tNOTsNOTu', 't&sNOTu'], [['t', 'u'], ['t', 's'],
                                                     ['s', 't', 'u'], ['t'],
                                                     ['t', 'v']], ['t']),
         (['nonex'], [['t1'], ['t1,t2'], []], [])
     ]:
         # 1) Create tag stats
         builder = TagStatisticsBuilder(Criticality(crit_tags),
                                        combined=[(t, '')
                                                  for t in comb_tags])
         all_tags = []
         for tags in tests_tags:
             builder.add_test(TestCase(status='PASS', tags=tags), )
             all_tags.extend(tags)
         # 2) Actual values
         names = [stat.name for stat in builder.stats]
         # 3) Expected values
         exp_crit = []
         exp_noncr = []
         for tag in utils.normalize_tags(all_tags):
             if tag in crit_tags:
                 exp_crit.append(tag)
             else:
                 exp_noncr.append(tag)
         exp_names = exp_crit + sorted(comb_tags) + exp_noncr
         # 4) Verify names (match counts were already verified)
         assert_equals(names, exp_names)
예제 #8
0
 def test_remove_dupes(self):
     for inp in ['dupe', 'DUPE', ' d u p e '], ['d U', 'du', 'DU', 'Du']:
         assert_equals(normalize_tags(inp), [inp[0]])
예제 #9
0
 def test_sorting(self):
     for inp, exp in [(['SORT', '1', 'B', '2',
                        'a'], ['1', '2', 'a', 'B', 'SORT']),
                      (['all', 'A L L', 'NONE', '10', '1', 'A', 'a',
                        ''], ['1', '10', 'A', 'all'])]:
         assert_equals(normalize_tags(inp), exp)
 def test_sorting(self):
     for inp, exp in [(['SORT','1','B','2','a'], ['1','2','a','B','SORT']),
                      (['all', 'A L L', 'NONE', '10', '1', 'A', 'a', ''],
                        ['1', '10', 'A', 'all'])]:
         assert_equals(normalize_tags(inp), exp)
예제 #11
0
 def test_sorting(self):
     for inp, exp in [
         (["SORT", "1", "B", "2", "a"], ["1", "2", "a", "B", "SORT"]),
         (["all", "A L L", "NONE", "10", "1", "A", "a", ""], ["1", "10", "A", "all"]),
     ]:
         assert_equals(normalize_tags(inp), exp)
 def test_case_and_space(self):
     for inp in ['lower'], ['MiXeD', 'UPPER'], ['a few', 'spaces here']:
         assert_equals(normalize_tags(inp), inp)
 def test_remove_empty_and_none(self):
     for inp in ['', 'X', '', '  ', '\n'], ['none', 'N O N E', 'X', '', '_']:
         assert_equals(normalize_tags(inp), ['X'])
예제 #14
0
 def _get_tags(self, tags):
     if isinstance(tags, utils.MultiMatcher):
         return tags
     return utils.MultiMatcher(utils.normalize_tags(tags or []), ignore=['_'])
예제 #15
0
파일: model.py 프로젝트: pombredanne/RIDE
 def _get_tags(self, tags):
     if isinstance(tags, utils.MultiMatcher):
         return tags
     return utils.MultiMatcher(utils.normalize_tags(tags or []), ignore=['_'])
예제 #16
0
 def _tags(self, tags):
     if isinstance(tags, basestring):
         tags = [tags]
     return normalize_tags(tags or [])
예제 #17
0
 def set_tags(self, tags):
     if tags:
         for test in self.tests:
             test.tags = utils.normalize_tags(test.tags + tags)
         for suite in self.suites:
             suite.set_tags(tags)
예제 #18
0
파일: tags.py 프로젝트: IlfirinPL/RIDE
 def _tags(self, tags):
     if isinstance(tags, basestring):
         tags = [tags]
     return utils.normalize_tags(tags or [])
예제 #19
0
 def test_remove_dupes(self):
     for inp in ["dupe", "DUPE", " d u p e "], ["d U", "du", "DU", "Du"]:
         assert_equals(normalize_tags(inp), [inp[0]])
 def set(self, tags, nons):
     self.tags = utils.normalize_tags(tags or [])
     self.nons = utils.normalize_tags(nons or [])
예제 #21
0
 def test_case_and_space(self):
     for inp in ["lower"], ["MiXeD", "UPPER"], ["a few", "spaces here"]:
         assert_equals(normalize_tags(inp), inp)
예제 #22
0
 def test_remove_empty_and_none(self):
     for inp in ["", "X", "", "  ", "\n"], ["none", "N O N E", "X", "", "_"]:
         assert_equals(normalize_tags(inp), ["X"])
예제 #23
0
파일: model.py 프로젝트: pombredanne/RIDE
 def set_tags(self, tags):
     if tags:
         for test in self.tests:
             test.tags = utils.normalize_tags(test.tags + tags)
         for suite in self.suites:
             suite.set_tags(tags)
예제 #24
0
 def test_underscore(self):
     assert_equals(normalize_tags(["a_tag", "a tag", "ATag"]), ["a_tag"])
     assert_equals(normalize_tags(["tag", "_t_a_g_"]), ["tag"])
 def test_no_tasg(self):
     assert_equals(normalize_tags([]), [])
예제 #26
0
 def test_case_and_space(self):
     for inp in ['lower'], ['MiXeD', 'UPPER'], ['a few', 'spaces here']:
         assert_equals(normalize_tags(inp), inp)
 def test_underscore(self):
     assert_equals(normalize_tags(['a_tag', 'a tag', 'ATag']), ['a_tag'])
     assert_equals(normalize_tags(['tag', '_t_a_g_']), ['tag'])
예제 #28
0
 def test_underscore(self):
     assert_equals(normalize_tags(['a_tag', 'a tag', 'ATag']), ['a_tag'])
     assert_equals(normalize_tags(['tag', '_t_a_g_']), ['tag'])
 def test_remove_dupes(self):
     for inp in ['dupe', 'DUPE', ' d u p e '], ['d U', 'du', 'DU', 'Du']:
         assert_equals(normalize_tags(inp), [inp[0]])
예제 #30
0
 def test_remove_empty_and_none(self):
     for inp in ['', 'X', '', '  ',
                 '\n'], ['none', 'N O N E', 'X', '', '_']:
         assert_equals(normalize_tags(inp), ['X'])
예제 #31
0
 def test_no_tasg(self):
     assert_equals(normalize_tags([]), [])
예제 #32
0
 def set(self, tags, nons):
     self.tags = utils.normalize_tags(tags or [])
     self.nons = utils.normalize_tags(nons or [])