100% coverage

This commit is contained in:
shamoon
2024-01-12 02:31:49 -08:00
parent e5348b8b7b
commit 80699183c9
2 changed files with 45 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import json
import os
from django.contrib.auth.models import User
from rest_framework import status
@@ -122,3 +123,37 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
config = ApplicationConfiguration.objects.first()
self.assertEqual(config.user_args, None)
def test_api_replace_app_logo(self):
"""
GIVEN:
- Existing config with app_logo specified
WHEN:
- API to replace app_logo is called
THEN:
- old app_logo file is deleted
"""
with open(
os.path.join(os.path.dirname(__file__), "samples", "simple.jpg"),
"rb",
) as f:
self.client.patch(
f"{self.ENDPOINT}1/",
{
"app_logo": f,
},
)
config = ApplicationConfiguration.objects.first()
old_logo = config.app_logo
self.assertTrue(os.path.exists(old_logo.path))
with open(
os.path.join(os.path.dirname(__file__), "samples", "simple.png"),
"rb",
) as f:
self.client.patch(
f"{self.ENDPOINT}1/",
{
"app_logo": f,
},
)
self.assertFalse(os.path.exists(old_logo.path))