コード例 #1
0
 def test_get_link_returns_correct_link_when_matches(self):
     for arg, exp in [(('smoke', 'http://tobacco.com', 'Lung_cancer'),
                       ('http://tobacco.com', 'Lung cancer')),
                      (('tag', 'ftp://foo:809/bar.zap', 'Foo_in a Bar'),
                       ('ftp://foo:809/bar.zap', 'Foo in a Bar'))]:
         link = TagStatLink(*arg)
         assert_equal(exp, link.get_link(arg[0]))
コード例 #2
0
 def test_get_link_returns_correct_link_when_matches(self):
     for arg, exp in [(('smoke', 'http://tobacco.com', 'Lung_cancer'),
                       ('http://tobacco.com', 'Lung cancer')),
                      (('tag', 'ftp://foo:809/bar.zap', 'Foo_in a Bar'),
                       ('ftp://foo:809/bar.zap', 'Foo in a Bar'))]:
         link = TagStatLink(*arg)
         assert_equals(exp, link.get_link(arg[0]))
コード例 #3
0
 def test_matches_are_ignored_in_pattern_substitution(self):
     link = TagStatLink('???-*-*-?', '%4-%2-%2-%4', 'Tracker')
     assert_equal(link.get_link('AAA-XXX-ABC-B'), ('B-XXX-XXX-B', 'Tracker'))
コード例 #4
0
 def test_pattern_substitution_with_multiple_matches(self):
     link = TagStatLink('?-*', 'http://tracker/?id=%1-%2', 'Tracker')
     for id1, id2 in [('1', '2'), ('3', '45'), ('f', 'bar')]:
         exp = ('http://tracker/?id=%s-%s' % (id1, id2), 'Tracker')
         assert_equal(exp, link.get_link('%s-%s' % (id1, id2)))
コード例 #5
0
 def test_pattern_substitution_with_multiple_substitutions(self):
     link = TagStatLink('??-?-*', '%3-%3-%1-%2-%3', 'Tracker')
     assert_equal(link.get_link('aa-b-XXX'), ('XXX-XXX-aa-b-XXX', 'Tracker'))
コード例 #6
0
 def test_pattern_match(self):
     link = TagStatLink('f?o*r', 'http://foo/bar.html', 'FooBar')
     for tag in ['foobar', 'foor', 'f_ofoobarfoobar', 'fOoBAr']:
         assert_equal(link.get_link(tag), ('http://foo/bar.html', 'FooBar'))
コード例 #7
0
 def test_pattern_substitution_with_one_match(self):
     link = TagStatLink('tag-*', 'http://tracker/?id=%1', 'Tracker')
     for id in ['1', '23', '456']:
         exp = ('http://tracker/?id=%s' % id, 'Tracker')
         assert_equal(exp, link.get_link('tag-%s' % id))
コード例 #8
0
 def test_pattern_matches_case_insensitively(self):
     exp = 'http://tobacco.com', 'Lung cancer'
     link = TagStatLink('smoke', *exp)
     for tag in ['Smoke', 'SMOKE', 'smoke']:
         assert_equal(exp, link.get_link(tag))
コード例 #9
0
 def test_pattern_matches_when_spaces(self):
     exp = 'http://tobacco.com', 'Lung cancer'
     link = TagStatLink('smoking kills', *exp)
     for tag in ['Smoking Kills', 'SMOKING KILLS']:
         assert_equal(exp, link.get_link(tag))
コード例 #10
0
 def test_get_link_returns_none_when_no_match(self):
     link = TagStatLink('smoke', 'http://tobacco.com', 'Lung cancer')
     for tag in ['foo', 'b a r', 's moke']:
         assert_none(link.get_link(tag))
コード例 #11
0
 def test_get_link_returns_none_when_no_match(self):
     link = TagStatLink('smoke', 'http://tobacco.com', 'Lung cancer')
     for tag in ['foo', 'b a r', 's moke']:
         assert_none(link.get_link(tag))
コード例 #12
0
 def test_pattern_substitution_with_multiple_substitutions(self):
     link = TagStatLink('??-?-*', '%3-%3-%1-%2-%3', 'Tracker')
     assert_equals(link.get_link('aa-b-XXX'),
                   ('XXX-XXX-aa-b-XXX', 'Tracker'))
コード例 #13
0
 def test_matches_are_ignored_in_pattern_substitution(self):
     link = TagStatLink('???-*-*-?', '%4-%2-%2-%4', 'Tracker')
     assert_equals(link.get_link('AAA-XXX-ABC-B'),
                   ('B-XXX-XXX-B', 'Tracker'))
コード例 #14
0
 def test_pattern_substitution_with_multiple_matches(self):
     link = TagStatLink('?-*', 'http://tracker/?id=%1-%2', 'Tracker')
     for id1, id2 in [('1', '2'), ('3', '45'), ('f', 'bar')]:
         exp = ('http://tracker/?id=%s-%s' % (id1, id2), 'Tracker')
         assert_equals(exp, link.get_link('%s-%s' % (id1, id2)))
コード例 #15
0
 def test_pattern_substitution_with_one_match(self):
     link = TagStatLink('tag-*', 'http://tracker/?id=%1', 'Tracker')
     for id in ['1', '23', '456']:
         exp = ('http://tracker/?id=%s' % id, 'Tracker')
         assert_equals(exp, link.get_link('tag-%s' % id))
コード例 #16
0
 def test_pattern_match(self):
     link = TagStatLink('f?o*r', 'http://foo/bar.html', 'FooBar')
     for tag in ['foobar', 'foor', 'f_ofoobarfoobar', 'fOoBAr']:
         assert_equals(link.get_link(tag),
                       ('http://foo/bar.html', 'FooBar'))
コード例 #17
0
 def test_pattern_matches_when_spaces(self):
     exp = 'http://tobacco.com', 'Lung cancer'
     link = TagStatLink('smoking kills', *exp)
     for tag in ['Smoking Kills', 'SMOKING KILLS']:
         assert_equals(exp, link.get_link(tag))
コード例 #18
0
 def test_pattern_matches_case_insensitively(self):
     exp = 'http://tobacco.com', 'Lung cancer'
     link = TagStatLink('smoke', *exp)
     for tag in ['Smoke', 'SMOKE', 'smoke']:
         assert_equals(exp, link.get_link(tag))