Merge remote-tracking branch 'inventree/master' into part-stocktake

This commit is contained in:
Oliver 2022-12-22 12:43:09 +11:00
commit a83943ad50

View File

@ -1,5 +1,7 @@
"""Unit tests for base mixins for plugins."""
import os
from django.conf import settings
from django.test import TestCase
from django.urls import include, re_path, reverse
@ -203,6 +205,13 @@ class APICallMixinTest(BaseMixinDefinition, TestCase):
self.mixin = MixinCls()
# If running in github workflow, make use of GITHUB_TOKEN
if settings.TESTING:
token = os.getenv('GITHUB_TOKEN', None)
if token:
self.mixin.set_setting('API_TOKEN', token)
class WrongCLS(APICallMixin, InvenTreePlugin):
pass
@ -222,7 +231,7 @@ class APICallMixinTest(BaseMixinDefinition, TestCase):
# api_headers
headers = self.mixin.api_headers
self.assertEqual(headers, {'Bearer': '', 'Content-Type': 'application/json'})
self.assertEqual(headers['Content-Type'], 'application/json')
def test_args(self):
"""Test that building up args work."""
@ -251,10 +260,6 @@ class APICallMixinTest(BaseMixinDefinition, TestCase):
self.assertTrue(result)
self.assertEqual(result.reason, 'OK')
# api_call with full url
result = self.mixin.api_call('orgs/inventree')
self.assertTrue(result)
# api_call with post and data
result = self.mixin.api_call(
'https://reqres.in/api/users/',