forked from eggpi/citationhunt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.py
37 lines (32 loc) · 1.33 KB
/
config_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import config
import re
import unittest
class ConfigTest(unittest.TestCase):
@classmethod
def add_validate_categories_test(cls, cfg):
def test(self):
# Categories must have underscores instead of spaces.
self.assertNotIn(' ', cfg.hidden_category)
self.assertNotIn(' ', cfg.citation_needed_category)
name = 'test_' + cfg.lang_code + '_category_names_underscores'
setattr(cls, name, test)
@classmethod
def add_validate_templates_test(cls, cfg):
def test(self):
# Templates should contain spaces, not underscores.
for tpl in cfg.citation_needed_templates:
self.assertNotIn('_', tpl)
setattr(cls, 'test_' + cfg.lang_code + '_template_names_spaces', test)
@classmethod
def add_validate_wikipedia_domain_test(cls, cfg):
def test(self):
self.assertTrue(re.match('^[a-z]+.wikipedia.org$',
cfg.wikipedia_domain))
setattr(cls, 'test_' + cfg.lang_code + '_wikipedia_domain', test)
if __name__ == '__main__':
for lc in config.LANG_CODES_TO_LANG_NAMES:
cfg = config.get_localized_config(lc)
ConfigTest.add_validate_categories_test(cfg)
ConfigTest.add_validate_templates_test(cfg)
ConfigTest.add_validate_wikipedia_domain_test(cfg)
unittest.main()