2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Merge branch 'master' of https://github.com/inventree/InvenTree into style-fixes

This commit is contained in:
Matthias Mair
2022-05-21 23:57:41 +02:00
28 changed files with 296 additions and 483 deletions

View File

@ -1,14 +1,13 @@
""" Unit tests for Stock views (see views.py) """
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.test import TestCase
from django.urls import reverse
from InvenTree.helpers import InvenTreeTestCase
# from common.models import InvenTreeSetting
class StockViewTestCase(TestCase):
class StockViewTestCase(InvenTreeTestCase):
fixtures = [
'category',
@ -19,35 +18,7 @@ class StockViewTestCase(TestCase):
'stock',
]
def setUp(self):
super().setUp()
# Create a user
user = get_user_model()
self.user = user.objects.create_user(
username='username',
email='user@email.com',
password='password'
)
self.user.is_staff = True
self.user.save()
# Put the user into a group with the correct permissions
group = Group.objects.create(name='mygroup')
self.user.groups.add(group)
# Give the group *all* the permissions!
for rule in group.rule_sets.all():
rule.can_view = True
rule.can_change = True
rule.can_add = True
rule.can_delete = True
rule.save()
self.client.login(username='username', password='password')
roles = 'all'
class StockListTest(StockViewTestCase):

View File

@ -1,11 +1,10 @@
import datetime
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.db.models import Sum
from django.test import TestCase
from build.models import Build
from InvenTree.helpers import InvenTreeTestCase
from InvenTree.status_codes import StockHistoryCode
from part.models import Part
@ -13,7 +12,7 @@ from .models import (StockItem, StockItemTestResult, StockItemTracking,
StockLocation)
class StockTest(TestCase):
class StockTest(InvenTreeTestCase):
"""
Tests to ensure that the stock location tree functions correcly
"""
@ -28,6 +27,8 @@ class StockTest(TestCase):
]
def setUp(self):
super().setUp()
# Extract some shortcuts from the fixtures
self.home = StockLocation.objects.get(name='Home')
self.bathroom = StockLocation.objects.get(name='Bathroom')
@ -38,14 +39,6 @@ class StockTest(TestCase):
self.drawer2 = StockLocation.objects.get(name='Drawer_2')
self.drawer3 = StockLocation.objects.get(name='Drawer_3')
# Create a user
user = get_user_model()
user.objects.create_user('username', 'user@email.com', 'password')
self.client.login(username='username', password='password')
self.user = user.objects.get(username='username')
# Ensure the MPTT objects are correctly rebuild
Part.objects.rebuild()
StockItem.objects.rebuild()