Django Unit Test Case
As shown in the docs
:
router.register(r'users', UserViewSet)
The example above would generate the following URL patterns:
URL pattern: ^users/$ Name: 'user-list'
URL pattern: ^users/{pk}/$ Name: 'user-detail'
URL pattern: ^accounts/$ Name: 'account-list'
URL pattern: ^accounts/{pk}/$ Name: 'account-detail'
The url name you seem to want to use then is user-list
, but since you used basename='users'
it would be users-list
so:
def test_user_view(self):
response = self.client.get(reverse('users-list'))
# ...