title: Test POST method to Django REST viewsets
body: <p>Docs says only mapping of <code>GET</code></p>
  
  <blockquote>
    <p>user_list = UserViewSet.as_view({'get': 'list'})<br>
    user_detail = UserViewSet.as_view({'get': 'retrieve'})</p>
  </blockquote>
  
  <p><strong>tests.py</strong>:<br></p>
  
  <pre><code>def test_admin_can_create_role(userprofiles, aoo_admin, bug_manager, note_admin):
      aoo = User.objects.get(username='aoo')
      factory = APIRequestFactory()
      view = RoleViewSet.as_view()
      url = reverse('api:role-list')
      data = {
          'name': 'FirstAdmin',
          'type': Role.RoleType.admin,
          'company': 1,
      }
      request = factory.post(url, data=data, format='json')
      force_authenticate(request, user=aoo)
      response = view(request)
      assert 201 == response.data
  </code></pre>
  
  <p><strong>viewsets.py</strong><br></p>
  
  <pre><code>class RoleViewSetPermission(permissions.BasePermission):
      message = 'Only Manager or Admin are allowed'
  
      def has_permission(self, request, view):
          user = request.user
          return user.has_perm('roles.add_role') \
                 and user.has_perm('roles.change_role') \
                 and user.has_perm('roles.delete_role')
  
  
  class RoleViewSet(viewsets.ModelViewSet):
      permission_classes = (RoleViewSetPermission,)
      queryset = Role.objects.all()
      serializer_class = RoleSerializer
      filter_backends = (filters.DjangoFilterBackend, SearchFilter)
      filter_class = RoleFilter
      search_fields = ('name', 'description', 'user__username', 'company__name', 'company__name_th')
  
      def filter_queryset(self, queryset):
          try:
              company = self.request.user.user_profile.companyappid.company
          except AttributeError:
              logger.error(f'{self.request.user} has AttributeError')
              return Role.objects.none()
          else:
              logger.info(f'{self.request.user} is {company} member')
              return queryset.filter(company=company)
  </code></pre>
  
  <p><strong>Trackback:</strong><br></p>
  
  <pre><code>cls = &lt;class 'poinkbackend.apps.roles.api.viewsets.RoleViewSet'&gt;, actions = None, initkwargs = {}
  
      @classonlymethod
      def as_view(cls, actions=None, **initkwargs):
          """
              Because of the way class based views create a closure around the
              instantiated view, we need to totally reimplement `.as_view`,
              and slightly modify the view function that is created and returned.
              """
          # The suffix initkwarg is reserved for identifying the viewset type
          # eg. 'List' or 'Instance'.
          cls.suffix = None
  
          # actions must not be empty
          if not actions:
  &gt;           raise TypeError("The `actions` argument must be provided when "
                              "calling `.as_view()` on a ViewSet. For example "
                              "`.as_view({'get': 'list'})`")
  E           TypeError: The `actions` argument must be provided when calling `.as_view()` on a ViewSet. For example `.as_view({'get': 'list'})`
  
  ../../.pyenv/versions/3.6.3/envs/poink/lib/python3.6/site-packages/rest_framework/viewsets.py:55: TypeError
  </code></pre>
  
  <p><strong>Question:</strong><br>
  How to do <code>force_authenticate</code> and <code>request.post</code> to the <code>viewsets</code>?
  I have no problem with get. It has an answer already in the <code>SO</code></p>
  
  <p><strong>References:</strong><br>
  <a href="http://www.django-rest-framework.org/api-guide/viewsets/" rel="nofollow noreferrer">http://www.django-rest-framework.org/api-guide/viewsets/</a></p>