Skip to content

Commit

Permalink
Add tests for inventree#7164
Browse files Browse the repository at this point in the history
  • Loading branch information
matmair committed Sep 1, 2024
1 parent 26101b4 commit 47b9d32
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/backend/InvenTree/stock/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2211,3 +2211,38 @@ def test_metadata(self):
'api-stock-item-metadata': StockItem,
}.items():
self.metatester(apikey, model)


class StockStatisticsTest(StockAPITestCase):
"""Tests for the StockStatistics API endpoints."""

fixtures = [*StockAPITestCase.fixtures, 'build']

def test_test_statics(self):
"""Test the test statistics API endpoints."""
part = Part.objects.first()
response = self.get(
reverse('api-test-statistics-by-part', kwargs={'pk': part.pk}),
{},
expected_code=200,
)
self.assertEqual(response.data, [{}])

# Now trackable part
part1 = Part.objects.filter(trackable=True).first()
response = self.get(
reverse(
'api-test-statistics-by-part',
kwargs={'pk': part1.stock_items.first().pk},
),
{},
expected_code=404,
)
self.assertIn('detail', response.data)

# 105

bld = build.models.Build.objects.first()
url = reverse('api-test-statistics-by-build', kwargs={'pk': bld.pk})
response = self.get(url, {}, expected_code=200)
self.assertEqual(response.data, [{}])

0 comments on commit 47b9d32

Please sign in to comment.