Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
- Add test for plugin lookup via "key" attribute
  • Loading branch information
SchrodingersGat committed May 15, 2024
1 parent 98a53ac commit 0870c7e
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions test/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,30 @@
class PluginTest(InvenTreeTestCase):
"""Unit tests for plugin functionality."""

def test_plugin_lookup(self):
"""Test plugin lookup by key."""

if self.api.api_version < InvenTreePlugin.MIN_API_VERSION:
return

plugins = InvenTreePlugin.list(self.api)

self.assertGreater(len(plugins), 0)

p1 = plugins[0]

# Access the plugin via primary key value
p2 = InvenTreePlugin(self.api, p1.key)

self.assertEqual(p1.key, p2.key)
self.assertEqual(p1.name, p2.name)

self.assertEqual(p1._data['pk'], p2._data['pk'])

def test_plugin_list(self):
"""Test plugin list API."""

if self.api.api_version < 197:
if self.api.api_version < InvenTreePlugin.MIN_API_VERSION:
return

plugins = InvenTreePlugin.list(self.api)
Expand All @@ -41,7 +61,7 @@ def test_plugin_list(self):
def test_filter_by_active(self):
"""Filter by plugin active status."""

if self.api.api_version < 197:
if self.api.api_version < InvenTreePlugin.MIN_API_VERSION:
return

plugins = InvenTreePlugin.list(self.api, active=True)
Expand All @@ -55,7 +75,7 @@ def test_filter_by_active(self):
def test_filter_by_builtin(self):
"""Filter by plugin builtin status."""

if self.api.api_version < 197:
if self.api.api_version < InvenTreePlugin.MIN_API_VERSION:
return

plugins = InvenTreePlugin.list(self.api, builtin=True)
Expand All @@ -67,7 +87,7 @@ def test_filter_by_builtin(self):
def test_filter_by_mixin(self):
"""Test that we can filter by 'mixin' attribute."""

if self.api.api_version < 197:
if self.api.api_version < InvenTreePlugin.MIN_API_VERSION:
return

n = InvenTreePlugin.count(self.api)
Expand Down

0 comments on commit 0870c7e

Please sign in to comment.