Add tests to the platform app
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -9,6 +9,8 @@ except ImportError:
|
||||
from yaml import SafeLoader
|
||||
|
||||
from django.template import loader
|
||||
from django.template.base import Template
|
||||
from django.template.context import Context
|
||||
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -34,8 +36,10 @@ class PlatformTemplate(object):
|
||||
context = {}
|
||||
context_defaults = {}
|
||||
label = None
|
||||
name = None
|
||||
settings = None
|
||||
template_name = None
|
||||
template_string = None
|
||||
variables = None
|
||||
|
||||
@classmethod
|
||||
@@ -99,10 +103,15 @@ class PlatformTemplate(object):
|
||||
stream=context_string, Loader=SafeLoader
|
||||
)
|
||||
)
|
||||
return loader.render_to_string(
|
||||
template_name=self.get_template_name(),
|
||||
context=context
|
||||
)
|
||||
|
||||
if self.template_string:
|
||||
template = Template(template_string=self.template_string)
|
||||
return template.render(context=Context(dict_=context))
|
||||
else:
|
||||
return loader.render_to_string(
|
||||
template_name=self.get_template_name(),
|
||||
context=context
|
||||
)
|
||||
|
||||
|
||||
class PlatformTemplateSupervisord(PlatformTemplate):
|
||||
@@ -159,9 +168,7 @@ class PlatformTemplateSupervisord(PlatformTemplate):
|
||||
)
|
||||
|
||||
def get_context(self):
|
||||
return {
|
||||
'workers': Worker.all()
|
||||
}
|
||||
return {'workers': Worker.all()}
|
||||
|
||||
|
||||
class PlatformTemplateSupervisordDocker(PlatformTemplate):
|
||||
|
||||
Reference in New Issue
Block a user