Добавлен класс ViewSetAction
This commit is contained in:
41
net/xeaf/rack/tests/enums/view_set_action_tests.py
Normal file
41
net/xeaf/rack/tests/enums/view_set_action_tests.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# DRF Rack
|
||||
# Библиотека классов расширений для Django REST Framework
|
||||
#
|
||||
# Автор: Николай В. Анохин <n.anokhin@xeaf.net>
|
||||
# Все права защищены. Лицензия: MIT
|
||||
|
||||
"""
|
||||
Описание класса ViewSetActionTests
|
||||
"""
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
from net.xeaf.rack.enums import ViewSetAction
|
||||
|
||||
|
||||
class ViewSetActionTests(SimpleTestCase):
|
||||
"""
|
||||
Тесты для ViewSetAction
|
||||
"""
|
||||
|
||||
def test_get_method_returns_correct_mapping(self):
|
||||
"""
|
||||
Проверяет, что get_method возвращает правильные HTTP-методы для всех действий
|
||||
"""
|
||||
|
||||
self.assertEqual(ViewSetAction.get_method(ViewSetAction.LIST), "item_list")
|
||||
self.assertEqual(ViewSetAction.get_method(ViewSetAction.RETRIEVE), "item_retrieve")
|
||||
self.assertEqual(ViewSetAction.get_method(ViewSetAction.CREATE), "item_create")
|
||||
self.assertEqual(ViewSetAction.get_method(ViewSetAction.UPDATE), "item_update")
|
||||
self.assertEqual(ViewSetAction.get_method(ViewSetAction.PARTIAL_UPDATE), "item_partial_update")
|
||||
self.assertEqual(ViewSetAction.get_method(ViewSetAction.DESTROY), "item_destroy")
|
||||
|
||||
def test_get_method_with_invalid_action_raises_error(self):
|
||||
"""
|
||||
Проверяет поведение метода при передаче невалидного значения
|
||||
"""
|
||||
|
||||
invalid_action = "invalid_action"
|
||||
|
||||
with self.assertRaises(Exception): # Будет вызван MatchError или ValueError в зависимости от настроек linter/python
|
||||
ViewSetAction.get_method(invalid_action) # type: ignore
|
||||
Reference in New Issue
Block a user