chore(backend): increase coverage (#9039)

* move version tests

* factor out read_license_file

* add testing for license file

* ignore special case when we create the schema

* extent no found api tests

* extend info view tests

* try fixing test?

* fix?

* test user create api

* measure impact of removing bom import

* remove dead code

* Revert "measure impact of removing bom import"

This reverts commit bb31db05e3.

* remove dead code

* remove plugin tags that were made for CUI

* add testing for filters

* add test for config delete

* add more api tests

* adjust tests

* fix test

* use superuser

* adapt error code

* Add test for https://github.com/inventree/InvenTree/pull/9077

* add mixin_available mixin

* make check_reload more observable

* test check_reload too

* test clean_barcode

* reset after testing

* extend datamatrix testing

* debug print

* fix assertation
This commit is contained in:
Matthias Mair authored and GitHub committed 2025-02-17 11:21:58 +11:00
1 parent ed4240a54c
commit 4a9138cc3b
14 files changed
+284 -239

No files matched your search

+28 -1
View File
@@ -40,7 +40,8 @@ class UserAPITests(InvenTreeAPITestCase):
def test_user_api(self):
"""Tests for User API endpoints."""
response = self.get(reverse('api-user-list'), expected_code=200)
url = reverse('api-user-list')
response = self.get(url, expected_code=200)
# Check the correct number of results was returned
self.assertEqual(len(response.data), User.objects.count())
@@ -58,6 +59,32 @@ class UserAPITests(InvenTreeAPITestCase):
self.assertIn('pk', response.data)
self.assertIn('username', response.data)
# Test create user
response = self.post(url, expected_code=403)
self.assertIn(
'You do not have permission to perform this action.', str(response.data)
)
self.user.is_superuser = True
self.user.save()
response = self.post(
url,
data={
'username': 'test',
'first_name': 'Test',
'last_name': 'User',
'email': 'aa@example.org',
},
expected_code=201,
)
self.assertEqual(response.data['username'], 'test')
self.assertEqual(response.data['first_name'], 'Test')
self.assertEqual(response.data['last_name'], 'User')
self.assertEqual(response.data['is_staff'], False)
self.assertEqual(response.data['is_superuser'], False)
self.assertEqual(response.data['is_active'], True)
def test_group_api(self):
"""Tests for the Group API endpoints."""
response = self.get(reverse('api-group-list'), expected_code=200)