mirror of
https://github.com/inventree/InvenTree.git
synced 2025-09-13 14:11:37 +00:00
Unit test fixes (#10144)
- Account for longer query time in docker mode
This commit is contained in:
@@ -61,6 +61,8 @@ class PluginDetailAPITest(PluginMixin, InvenTreeAPITestCase):
|
||||
|
||||
def test_plugin_install(self):
|
||||
"""Test the plugin install command."""
|
||||
from django.conf import settings
|
||||
|
||||
url = reverse('api-plugin-install')
|
||||
|
||||
# invalid package name
|
||||
@@ -90,12 +92,18 @@ class PluginDetailAPITest(PluginMixin, InvenTreeAPITestCase):
|
||||
|
||||
self.assertEqual(data['success'], 'Installed plugin successfully')
|
||||
|
||||
# If we are running in docker mode, the plugin file is reinstalled too
|
||||
# In that case, the expected query count is higher
|
||||
query_count = 450 if settings.DOCKER else 350
|
||||
query_time = 60 if settings.DOCKER else 30
|
||||
|
||||
# valid - github url
|
||||
data = self.post(
|
||||
url,
|
||||
{'confirm': True, 'url': self.PKG_URL},
|
||||
expected_code=201,
|
||||
max_query_time=30,
|
||||
max_query_count=query_count,
|
||||
max_query_time=query_time,
|
||||
).data
|
||||
|
||||
self.assertEqual(data['success'], 'Installed plugin successfully')
|
||||
@@ -605,16 +613,23 @@ class PluginFullAPITest(PluginMixin, InvenTreeAPITestCase):
|
||||
@override_settings(PLUGIN_TESTING_SETUP=True)
|
||||
def test_full_process(self):
|
||||
"""Test the full plugin install/uninstall process via API."""
|
||||
from django.conf import settings
|
||||
|
||||
install_slug = 'inventree-brother-plugin'
|
||||
slug = 'brother'
|
||||
|
||||
# Note that if testing in docker mode, the plugin file is reinstalled too
|
||||
# In that case, the expected query count is higher
|
||||
query_count = 450 if settings.DOCKER else 350
|
||||
query_time = 60 if settings.DOCKER else 30
|
||||
|
||||
# Install a plugin
|
||||
data = self.post(
|
||||
reverse('api-plugin-install'),
|
||||
{'confirm': True, 'packagename': install_slug},
|
||||
expected_code=201,
|
||||
max_query_time=30,
|
||||
max_query_count=370,
|
||||
max_query_time=query_time,
|
||||
max_query_count=query_count,
|
||||
).data
|
||||
self.assertEqual(data['success'], 'Installed plugin successfully')
|
||||
|
||||
|
Reference in New Issue
Block a user