mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-01 17:51:23 +00:00
Remove defunct tests
This commit is contained in:
@@ -1669,31 +1669,6 @@ class NotesImageTest(InvenTreeAPITestCase):
|
|||||||
# Check that no extra database entries have been created
|
# Check that no extra database entries have been created
|
||||||
self.assertEqual(NotesImage.objects.count(), n)
|
self.assertEqual(NotesImage.objects.count(), n)
|
||||||
|
|
||||||
def test_valid_image(self):
|
|
||||||
"""Test upload of a valid image file."""
|
|
||||||
n = NotesImage.objects.count()
|
|
||||||
|
|
||||||
# Construct a simple image file
|
|
||||||
image = Image.new('RGB', (100, 100), color='red')
|
|
||||||
|
|
||||||
with io.BytesIO() as output:
|
|
||||||
image.save(output, format='PNG')
|
|
||||||
contents = output.getvalue()
|
|
||||||
|
|
||||||
self.post(
|
|
||||||
reverse('api-notes-image-list'),
|
|
||||||
data={
|
|
||||||
'image': SimpleUploadedFile(
|
|
||||||
'test.png', contents, content_type='image/png'
|
|
||||||
)
|
|
||||||
},
|
|
||||||
format='multipart',
|
|
||||||
expected_code=201,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Check that a new file has been created
|
|
||||||
self.assertEqual(NotesImage.objects.count(), n + 1)
|
|
||||||
|
|
||||||
def test_image_cleanup(self):
|
def test_image_cleanup(self):
|
||||||
"""Images no longer referenced in note content are deleted when the note is saved.
|
"""Images no longer referenced in note content are deleted when the note is saved.
|
||||||
|
|
||||||
|
|||||||
@@ -161,55 +161,6 @@ class CompanyTest(InvenTreeAPITestCase):
|
|||||||
len(self.get(url, data={'active': False}, expected_code=200).data), 1
|
len(self.get(url, data={'active': False}, expected_code=200).data), 1
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_company_notes(self):
|
|
||||||
"""Test the markdown 'notes' field for the Company model."""
|
|
||||||
company = Company.objects.first()
|
|
||||||
assert company
|
|
||||||
pk = company.pk
|
|
||||||
|
|
||||||
url = reverse('api-company-detail', kwargs={'pk': pk})
|
|
||||||
|
|
||||||
# Attempt to inject malicious markdown into the "notes" field
|
|
||||||
xss = [
|
|
||||||
'[Click me](javascript:alert(123))',
|
|
||||||
')',
|
|
||||||
')',
|
|
||||||
]
|
|
||||||
|
|
||||||
for note in xss:
|
|
||||||
response = self.patch(url, {'notes': note}, expected_code=400)
|
|
||||||
|
|
||||||
self.assertIn(
|
|
||||||
'Data contains prohibited markdown content', str(response.data)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Tests with disallowed tags
|
|
||||||
invalid_tags = [
|
|
||||||
'<iframe src="javascript:alert(123)"></iframe>',
|
|
||||||
'<canvas>A disallowed tag!</canvas>',
|
|
||||||
]
|
|
||||||
|
|
||||||
for note in invalid_tags:
|
|
||||||
response = self.patch(url, {'notes': note}, expected_code=400)
|
|
||||||
|
|
||||||
self.assertIn('Remove HTML tags from this value', str(response.data))
|
|
||||||
|
|
||||||
# The following markdown is safe, and should be accepted
|
|
||||||
good = [
|
|
||||||
'This is a **bold** statement',
|
|
||||||
'This is a *italic* statement',
|
|
||||||
'This is a [link](https://www.google.com)',
|
|
||||||
'This is an ',
|
|
||||||
'This is a `code` block',
|
|
||||||
'This text has ~~strikethrough~~ formatting',
|
|
||||||
'This text has a raw link - https://www.google.com - and should still pass the test',
|
|
||||||
]
|
|
||||||
|
|
||||||
for note in good:
|
|
||||||
response = self.patch(url, {'notes': note}, expected_code=200)
|
|
||||||
|
|
||||||
self.assertEqual(response.data['notes'], note)
|
|
||||||
|
|
||||||
def test_company_parameters(self):
|
def test_company_parameters(self):
|
||||||
"""Test for annotation of 'parameters' field in Company API."""
|
"""Test for annotation of 'parameters' field in Company API."""
|
||||||
url = reverse('api-company-list')
|
url = reverse('api-company-list')
|
||||||
|
|||||||
@@ -1363,23 +1363,6 @@ class PartAPITest(PartAPITestBase):
|
|||||||
date = datetime.fromisoformat(item['creation_date'])
|
date = datetime.fromisoformat(item['creation_date'])
|
||||||
self.assertGreaterEqual(date, date_compare)
|
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)
|
|
||||||
|
|
||||||
def test_output_options(self):
|
def test_output_options(self):
|
||||||
"""Test the output options for PartList list."""
|
"""Test the output options for PartList list."""
|
||||||
self.run_output_test(
|
self.run_output_test(
|
||||||
|
|||||||
Reference in New Issue
Block a user