mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	tests for template
This commit is contained in:
		
							
								
								
									
										23
									
								
								InvenTree/plugin/test_helpers.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								InvenTree/plugin/test_helpers.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
"""Unit tests for helpers.py"""
 | 
			
		||||
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
 | 
			
		||||
from .helpers import render_template
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class HelperTests(TestCase):
 | 
			
		||||
    """Tests for helpers"""
 | 
			
		||||
 | 
			
		||||
    def test_render_template(self):
 | 
			
		||||
        """Check if render_template helper works"""
 | 
			
		||||
        class ErrorSource:
 | 
			
		||||
            slug = 'sampleplg'
 | 
			
		||||
 | 
			
		||||
        # working sample
 | 
			
		||||
        response = render_template(ErrorSource(), 'sample/sample.html', {'abc': 123} )
 | 
			
		||||
        self.assertEqual(response, '<h1>123</h1>')
 | 
			
		||||
 | 
			
		||||
        # Wrong sample
 | 
			
		||||
        response = render_template(ErrorSource(), 'sample/wrongsample.html', {'abc': 123} )
 | 
			
		||||
        self.assertTrue('lert alert-block alert-danger' in response)
 | 
			
		||||
        self.assertTrue('Template file <em>sample/wrongsample.html</em>' in response)
 | 
			
		||||
							
								
								
									
										1
									
								
								InvenTree/templates/sample/sample.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								InvenTree/templates/sample/sample.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
<h1>{{abc}}</h1>
 | 
			
		||||
		Reference in New Issue
	
	Block a user