Create wrapper for config extension
This commit is contained in:
parent
58e825c43b
commit
f38e7a53df
3 changed files with 12 additions and 6 deletions
|
@ -26,6 +26,12 @@ class BaseTestCase(unittest.TestCase):
|
|||
except OSError:
|
||||
pass
|
||||
|
||||
def extend_config(self, *args):
|
||||
base_config = self.BASE_VALID_CONFIG.copy()
|
||||
for arg in args:
|
||||
base_config = dict(base_config, **arg)
|
||||
return base_config
|
||||
|
||||
def delete_templates(self):
|
||||
for template in [
|
||||
'header.html',
|
||||
|
|
|
@ -30,7 +30,7 @@ class ContextTestCase(BaseTestCase):
|
|||
self.assertIn(key, context)
|
||||
|
||||
def test_context_contains_context(self):
|
||||
config = dict(self.BASE_VALID_CONFIG, **{
|
||||
config = self.extend_config({
|
||||
'context': {
|
||||
'1': '2'
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class ContextTestCase(BaseTestCase):
|
|||
self.assertEqual(context['output_dir'], os.path.abspath(self.BASE_VALID_CONFIG['output_dir']))
|
||||
|
||||
def test_word_count(self):
|
||||
config = dict(self.BASE_VALID_CONFIG, **{
|
||||
config = self.extend_config({
|
||||
'show_word_count': True
|
||||
})
|
||||
context = get_context(config, 'testy test test')
|
||||
|
@ -61,14 +61,14 @@ class ContextTestCase(BaseTestCase):
|
|||
datetime.now().time(),
|
||||
datetime.now()
|
||||
]:
|
||||
config = dict(self.BASE_VALID_CONFIG, **{
|
||||
config = self.extend_config({
|
||||
'submission_date': value
|
||||
})
|
||||
context = get_context(config, 'test')
|
||||
self.assertEqual(context['submission_date'], value.strftime(consts.DATE_FORMAT))
|
||||
|
||||
def test_date_format(self):
|
||||
config = dict(self.BASE_VALID_CONFIG, **{
|
||||
config = self.extend_config({
|
||||
'submission_date': '2017-01-01'
|
||||
})
|
||||
context = get_context(config, 'test')
|
||||
|
|
|
@ -44,14 +44,14 @@ class AddBodyClassTestCase(BaseTestCase):
|
|||
class RenderTemplateTestCase(BaseTestCase):
|
||||
def test_renders_template(self):
|
||||
html = 'test {{ test }}'
|
||||
output = content.render_template(html, dict(self.BASE_VALID_CONFIG, **{
|
||||
output = content.render_template(html, self.extend_config({
|
||||
'test': 'content'
|
||||
}))
|
||||
self.assertEqual(output, 'test content')
|
||||
|
||||
def test_changes_nothing(self):
|
||||
html = 'test test'
|
||||
output = content.render_template(html, dict(self.BASE_VALID_CONFIG, **{
|
||||
output = content.render_template(html, self.extend_config({
|
||||
'test': 'content'
|
||||
}))
|
||||
self.assertEqual(output, html)
|
||||
|
|
Reference in a new issue