mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-11-04 01:47:59 +03:00 
			
		
		
		
	Move login required tests under a separate test case
This commit is contained in:
		
							parent
							
								
									7f9caf52ce
								
							
						
					
					
						commit
						63ce5c9414
					
				| 
						 | 
					@ -83,10 +83,6 @@ class ClassBasedViewIntegrationTests(TestCase):
 | 
				
			||||||
        assert response.status_code == status.HTTP_400_BAD_REQUEST
 | 
					        assert response.status_code == status.HTTP_400_BAD_REQUEST
 | 
				
			||||||
        assert sanitise_json_error(response.data) == expected
 | 
					        assert sanitise_json_error(response.data) == expected
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @unittest.skipUnless(DJANGO_VERSION >= (5, 1), 'Only for Django 5.1+')
 | 
					 | 
				
			||||||
    def test_django_51_login_required_disabled(self):
 | 
					 | 
				
			||||||
        assert self.view.login_required is False
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class FunctionBasedViewIntegrationTests(TestCase):
 | 
					class FunctionBasedViewIntegrationTests(TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
| 
						 | 
					@ -101,10 +97,6 @@ class FunctionBasedViewIntegrationTests(TestCase):
 | 
				
			||||||
        assert response.status_code == status.HTTP_400_BAD_REQUEST
 | 
					        assert response.status_code == status.HTTP_400_BAD_REQUEST
 | 
				
			||||||
        assert sanitise_json_error(response.data) == expected
 | 
					        assert sanitise_json_error(response.data) == expected
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @unittest.skipUnless(DJANGO_VERSION >= (5, 1), 'Only for Django 5.1+')
 | 
					 | 
				
			||||||
    def test_django_51_login_required_disabled(self):
 | 
					 | 
				
			||||||
        assert self.view.login_required is False
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestCustomExceptionHandler(TestCase):
 | 
					class TestCustomExceptionHandler(TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
| 
						 | 
					@ -146,3 +138,13 @@ class TestCustomSettings(TestCase):
 | 
				
			||||||
        response = self.view(request)
 | 
					        response = self.view(request)
 | 
				
			||||||
        assert response.status_code == 400
 | 
					        assert response.status_code == 400
 | 
				
			||||||
        assert response.data == {'error': 'SyntaxError'}
 | 
					        assert response.data == {'error': 'SyntaxError'}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@unittest.skipUnless(DJANGO_VERSION >= (5, 1), 'Only for Django 5.1+')
 | 
				
			||||||
 | 
					class TestLoginRequiredMiddlewareCompat(TestCase):
 | 
				
			||||||
 | 
					    def test_class_based_view_opted_out(self):
 | 
				
			||||||
 | 
					        class_based_view = BasicView.as_view()
 | 
				
			||||||
 | 
					        assert class_based_view.login_required is False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_function_based_view_opted_out(self):
 | 
				
			||||||
 | 
					        assert basic_view.login_required is False
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user