mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 04:55:44 +00:00
Unit testing fixes
This commit is contained in:
@ -3,13 +3,13 @@ from rest_framework import status
|
||||
|
||||
from django.urls import reverse
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import Group
|
||||
|
||||
from part.models import Part
|
||||
from stock.models import StockItem
|
||||
from company.models import Company
|
||||
|
||||
from InvenTree.status_codes import StockStatus
|
||||
from InvenTree.helpers import addUserPermissions
|
||||
|
||||
|
||||
class PartAPITest(APITestCase):
|
||||
@ -36,27 +36,20 @@ class PartAPITest(APITestCase):
|
||||
password='password'
|
||||
)
|
||||
|
||||
# Add the permissions required to access the API endpoints
|
||||
perms = [
|
||||
'view_part',
|
||||
'add_part',
|
||||
'change_part',
|
||||
'delete_part',
|
||||
'view_partcategory',
|
||||
'add_partcategory',
|
||||
'change_partcategory',
|
||||
'view_bomitem',
|
||||
'add_bomitem',
|
||||
'change_bomitem',
|
||||
'view_partattachment',
|
||||
'change_partattachment',
|
||||
'add_partattachment',
|
||||
'view_parttesttemplate',
|
||||
'add_parttesttemplate',
|
||||
'change_parttesttemplate',
|
||||
]
|
||||
# Put the user into a group with the correct permissions
|
||||
group = Group.objects.create(name='mygroup')
|
||||
self.user.groups.add(group)
|
||||
|
||||
addUserPermissions(self.user, perms)
|
||||
# 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()
|
||||
|
||||
group.save()
|
||||
|
||||
self.client.login(username='testuser', password='password')
|
||||
|
||||
|
Reference in New Issue
Block a user