mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Moar unit testing plz
This commit is contained in:
		| @@ -1,12 +1,18 @@ | |||||||
|  |  | ||||||
|  | import os | ||||||
|  |  | ||||||
| from django.test import TestCase | from django.test import TestCase | ||||||
| import django.core.exceptions as django_exceptions | import django.core.exceptions as django_exceptions | ||||||
| from django.core.exceptions import ValidationError | from django.core.exceptions import ValidationError | ||||||
|  |  | ||||||
| from .validators import validate_overage, validate_part_name | from .validators import validate_overage, validate_part_name | ||||||
| from . import helpers | from . import helpers | ||||||
|  | from .settings import STATIC_ROOT | ||||||
|  |  | ||||||
| from mptt.exceptions import InvalidMove | from mptt.exceptions import InvalidMove | ||||||
|  |  | ||||||
|  | from decimal import Decimal | ||||||
|  |  | ||||||
| from stock.models import StockLocation | from stock.models import StockLocation | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -48,6 +54,13 @@ class ValidatorTest(TestCase): | |||||||
| class TestHelpers(TestCase): | class TestHelpers(TestCase): | ||||||
|     """ Tests for InvenTree helper functions """ |     """ Tests for InvenTree helper functions """ | ||||||
|  |  | ||||||
|  |     def test_is_image(self): | ||||||
|  |         img = os.path.abspath(os.path.join(STATIC_ROOT, 'img/blank_image.png')) | ||||||
|  |         self.assertTrue(helpers.TestIfImage(img)) | ||||||
|  |  | ||||||
|  |         css = os.path.abspath(os.path.join(STATIC_ROOT, 'css/inventree.css')) | ||||||
|  |         self.assertFalse(helpers.TestIfImage(css)) | ||||||
|  |  | ||||||
|     def test_image_url(self): |     def test_image_url(self): | ||||||
|         """ Test if a filename looks like an image """ |         """ Test if a filename looks like an image """ | ||||||
|  |  | ||||||
| @@ -90,6 +103,11 @@ class TestHelpers(TestCase): | |||||||
|  |  | ||||||
|         self.assertEqual(helpers.getMediaUrl('xx/yy.png'), '/media/xx/yy.png') |         self.assertEqual(helpers.getMediaUrl('xx/yy.png'), '/media/xx/yy.png') | ||||||
|  |  | ||||||
|  |     def testDecimal2String(self): | ||||||
|  |          | ||||||
|  |         self.assertEqual(helpers.decimal2string(Decimal('1.2345000')), '1.2345') | ||||||
|  |         self.assertEqual(helpers.decimal2string('test'), 'test') | ||||||
|  |  | ||||||
|  |  | ||||||
| class TestQuoteWrap(TestCase): | class TestQuoteWrap(TestCase): | ||||||
|     """ Tests for string wrapping """ |     """ Tests for string wrapping """ | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -56,7 +56,7 @@ test: | |||||||
| # Run code coverage | # Run code coverage | ||||||
| coverage: | coverage: | ||||||
| 	cd InvenTree && python3 manage.py check | 	cd InvenTree && python3 manage.py check | ||||||
| 	coverage run InvenTree/manage.py test build common company order part stock InvenTree | 	cd InvenTree && coverage run manage.py test build common company order part stock InvenTree | ||||||
| 	coverage html | 	coverage html | ||||||
|  |  | ||||||
| # Install packages required to generate code docs | # Install packages required to generate code docs | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user