# DRF Rack # Библиотека классов расширений для Django REST Framework # # Автор: Николай В. Анохин # Все права защищены. Лицензия: 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