예제 #1
0
def validate_template(template, namespaces):
    """
    Validates that a template (or it's parents if check_inheritance is True)
    contain all given namespaces
    """
    if getattr(settings, 'SEKIZAI_IGNORE_VALIDATION', False):
        return True
    found = get_namespaces(template)
    for namespace in namespaces:
        if namespace not in found:
            return False
    return True
예제 #2
0
def validate_template(template, namespaces):
    """
    Validates that a template (or it's parents if check_inheritance is True)
    contain all given namespaces
    """
    if getattr(settings, 'SEKIZAI_IGNORE_VALIDATION', False):
        return True
    found = get_namespaces(template)
    for namespace in namespaces:
        if namespace not in found:
            return False
    return True
예제 #3
0
 def test_get_namespaces(self):
     self.assertEqual(get_namespaces('easy_inherit.html'), ['css'])
     self.assertEqual(get_namespaces('inherit/chain.html'), ['css', 'js'])
     self.assertEqual(get_namespaces('inherit/spacechain.html'), ['css', 'js'])
     self.assertEqual(get_namespaces('inherit/varchain.html'), [])
     self.assertEqual(get_namespaces('inherit/subvarchain.html'), [])
     self.assertEqual(get_namespaces('inherit/nullext.html'), [])
예제 #4
0
 def test_get_namespaces(self):
     self.assertEqual(get_namespaces('easy_inherit.html'), ['css'])
     self.assertEqual(get_namespaces('inherit/chain.html'), ['css', 'js'])
     self.assertEqual(get_namespaces('inherit/spacechain.html'), ['css', 'js'])
     self.assertEqual(get_namespaces('inherit/varchain.html'), [])
     self.assertEqual(get_namespaces('inherit/subvarchain.html'), [])
     self.assertEqual(get_namespaces('inherit/nullext.html'), [])
예제 #5
0
 def test_get_namespaces(self):
     self.assertEqual(get_namespaces("easy_inherit.html"), ["css"])
     self.assertEqual(get_namespaces("inherit/chain.html"), ["css", "js"])
     self.assertEqual(get_namespaces("inherit/spacechain.html"), ["css", "js"])
     self.assertEqual(get_namespaces("inherit/varchain.html"), [])
     self.assertEqual(get_namespaces("inherit/subvarchain.html"), [])
     self.assertEqual(get_namespaces("inherit/nullext.html"), [])
예제 #6
0
 def test_get_namespaces_null_ext(self):
     self.assertEqual(get_namespaces('inherit/nullext.html'), [])
예제 #7
0
 def test_get_namespaces_sub_var_inherit(self):
     self.assertEqual(get_namespaces('inherit/subvarchain.html'), [])
예제 #8
0
 def test_get_namespaces_space_chain_inherit(self):
     self.assertEqual(get_namespaces('inherit/spacechain.html'), ['css', 'js'])
예제 #9
0
 def test_get_namespaces_easy_inherit(self):
     self.assertEqual(get_namespaces('easy_inherit.html'), ['css'])
예제 #10
0
 def test_get_namespaces_null_ext(self):
     self.assertEqual(get_namespaces('inherit/nullext.html'), [])
예제 #11
0
 def test_get_namespaces_sub_var_inherit(self):
     self.assertEqual(get_namespaces('inherit/subvarchain.html'), [])
예제 #12
0
 def test_get_namespaces_space_chain_inherit(self):
     self.assertEqual(
         get_namespaces('inherit/spacechain.html'),
         ['css', 'js']
     )
예제 #13
0
 def test_get_namespaces_easy_inherit(self):
     self.assertEqual(get_namespaces('easy_inherit.html'), ['css'])
예제 #14
0
def get_test_namespaces(*args, **kwargs):
    return get_namespaces(*args, **kwargs)
예제 #15
0
 def test_get_namespaces_var_inherit(self):
     self.assertEqual(get_namespaces('sekizai_tests/inherit/varchain.html'), [])
예제 #16
0
 def test_get_namespaces_chain_inherit(self):
     self.assertEqual(get_namespaces('sekizai_tests/inherit/chain.html'), ['css', 'js'])