Skip to content

Commit

Permalink
stop
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Jan 7, 2025
1 parent 97cc505 commit d1eb78c
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/notificationprofile/destinations/test_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from django import forms

Check failure on line 1 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Verify Python formatting

Would reformat
from django.core.exceptions import ValidationError

Check failure on line 2 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:2:36: F401 `django.core.exceptions.ValidationError` imported but unused
from django.test import TestCase, tag

from rest_framework import status

Check failure on line 5 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:5:28: F401 `rest_framework.status` imported but unused
from rest_framework.test import APIClient, APIRequestFactory, APITestCase

Check failure on line 6 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:6:33: F401 `rest_framework.test.APIClient` imported but unused

Check failure on line 6 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:6:44: F401 `rest_framework.test.APIRequestFactory` imported but unused

Check failure on line 6 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:6:63: F401 `rest_framework.test.APITestCase` imported but unused

from argus.auth.factories import PersonUserFactory
from argus.notificationprofile.factories import DestinationConfigFactory, NotificationProfileFactory, TimeslotFactory

Check failure on line 9 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:9:49: F401 `argus.notificationprofile.factories.DestinationConfigFactory` imported but unused

Check failure on line 9 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:9:75: F401 `argus.notificationprofile.factories.NotificationProfileFactory` imported but unused

Check failure on line 9 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:9:103: F401 `argus.notificationprofile.factories.TimeslotFactory` imported but unused
from argus.notificationprofile.media.base import NotificationMedium
from argus.notificationprofile.models import DestinationConfig, Media

Check failure on line 11 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:11:46: F401 `argus.notificationprofile.models.DestinationConfig` imported but unused

Check failure on line 11 in tests/notificationprofile/destinations/test_base.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (F401)

tests/notificationprofile/destinations/test_base.py:11:65: F401 `argus.notificationprofile.models.Media` imported but unused
from argus.notificationprofile.serializers import RequestDestinationConfigSerializer
from argus.util.testing import connect_signals, disconnect_signals


class DummyNotificationMedium(NotificationMedium):
MEDIA_SETTINGS_KEY = "foo"
MEDIA_NAME = "Dummy"
MEDIA_SLUG = "dummy"

class Form(forms.Form):
foo = forms.IntegerField()


@tag("unit")
class NotificationMediumTests(TestCase):
def setUp(self):
self.user = PersonUserFactory()

def test_validate_croaks_on_medium_not_in_database(self):
data = {"settings": None}
form = DummyNotificationMedium.validate_settings(data, self.user)
#
# def test_validate_settings_croaks_on_empty_settings(self):
# data = {"settings": None}
# with self.assertRaises(ValidationError):
# DummmyNotificationMedium.validate_settings(data, self.user)
#
# def test_validate_settings_croaks_on_wrong_settings(self):
# data = {"settings": {"bar": False}}
# with self.assertRaises(ValidationError):
# DummyNotificationMedium.validate_settings(data, self.user)
#
# def test_validate_spits_out_a_valid_form_that_includes_cleaned_settings_and_user(self):
# data = {
# "media": DummyNotificationMedium.MEDIA_SLUG,
# "settings": {"foo": 1}
# }
# form = DummyNotificationMedium.validate(data, self.user)
# self.assertEqual(form.cleaned_data["settings"], data["settings"])
# self.assertEqual(form.cleaned_data["user"], self.user)
#
# def test_validate_croaks_on_invalid_input(self):
# data = {
# "media": "does not exist",
# "settings": {"foo": 1}
# }
# form = DummyNotificationMedium.validate(data, self.user)
# self.assertEqual(form.cleaned_data["settings"], data["settings"])
# self.assertEqual(form.cleaned_data["user"], self.user)

0 comments on commit d1eb78c

Please sign in to comment.