2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

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

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

View File

@ -1,5 +1,7 @@
"""Unit tests for base mixins for plugins.""" """Unit tests for base mixins for plugins."""
import os
from django.conf import settings from django.conf import settings
from django.test import TestCase from django.test import TestCase
from django.urls import include, re_path, reverse from django.urls import include, re_path, reverse
@ -203,6 +205,13 @@ class APICallMixinTest(BaseMixinDefinition, TestCase):
self.mixin = MixinCls() 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): class WrongCLS(APICallMixin, InvenTreePlugin):
pass pass
@ -222,7 +231,7 @@ class APICallMixinTest(BaseMixinDefinition, TestCase):
# api_headers # api_headers
headers = self.mixin.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): def test_args(self):
"""Test that building up args work.""" """Test that building up args work."""
@ -251,10 +260,6 @@ class APICallMixinTest(BaseMixinDefinition, TestCase):
self.assertTrue(result) self.assertTrue(result)
self.assertEqual(result.reason, 'OK') 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 # api_call with post and data
result = self.mixin.api_call( result = self.mixin.api_call(
'https://reqres.in/api/users/', 'https://reqres.in/api/users/',