Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat committed Jun 4, 2024
1 parent 4ae2c6c commit 9e483ab
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/backend/InvenTree/part/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,23 @@ def test_date_filters(self):
date = datetime.fromisoformat(item['creation_date'])
self.assertGreaterEqual(date, date_compare)

def test_part_notes(self):
"""Test the 'notes' field."""
# First test the 'LIST' endpoint - no notes information provided
url = reverse('api-part-list')

response = self.get(url, {'limit': 1}, expected_code=200)
data = response.data['results'][0]

self.assertNotIn('notes', data)

# Second, test the 'DETAIL' endpoint - notes information provided
url = reverse('api-part-detail', kwargs={'pk': data['pk']})

response = self.get(url, expected_code=200)

self.assertIn('notes', response.data)


class PartCreationTests(PartAPITestBase):
"""Tests for creating new Part instances via the API."""
Expand Down

0 comments on commit 9e483ab

Please sign in to comment.