Example #1
0
 def test_load_data(self):
     node = ProjectFactory()
     guid = node._id
     request = RequestFactory().get('/fake_path')
     view = NodeView()
     view = setup_view(view, request, guid=guid)
     res = view.get_object()
     nt.assert_is_instance(res, dict)
 def test_load_data(self):
     node = ProjectFactory()
     guid = node._id
     request = RequestFactory().get('/fake_path')
     view = NodeView()
     view = setup_view(view, request, guid=guid)
     res = view.get_object()
     nt.assert_is_instance(res, dict)
    def test_no_user_permissions_raises_error(self):
        user = AuthUserFactory()
        node = ProjectFactory()
        guid = node._id
        request = RequestFactory().get(reverse('nodes:node', kwargs={'guid': guid}))
        request.user = user

        with nt.assert_raises(PermissionDenied):
            NodeView.as_view()(request, guid=guid)
Example #4
0
    def test_no_user_permissions_raises_error(self):
        user = AuthUserFactory()
        node = ProjectFactory()
        guid = node._id
        request = RequestFactory().get(reverse('nodes:node', kwargs={'guid': guid}))
        request.user = user

        with nt.assert_raises(PermissionDenied):
            NodeView.as_view()(request, guid=guid)
 def test_name_data(self):
     node = ProjectFactory()
     guid = node._id
     request = RequestFactory().get('/fake_path')
     view = NodeView()
     view = setup_view(view, request, guid=guid)
     temp_object = view.get_object()
     view.object = temp_object
     res = view.get_context_data()
     nt.assert_equal(res[NodeView.context_object_name], temp_object)
Example #6
0
 def test_name_data(self):
     node = ProjectFactory()
     guid = node._id
     request = RequestFactory().get('/fake_path')
     view = NodeView()
     view = setup_view(view, request, guid=guid)
     temp_object = view.get_object()
     view.object = temp_object
     res = view.get_context_data()['node']
     nt.assert_equal(res, temp_object)
    def test_correct_view_permissions(self):
        user = AuthUserFactory()
        node = ProjectFactory()
        guid = node._id

        change_permission = Permission.objects.get(codename='view_node')
        user.user_permissions.add(change_permission)
        user.save()

        request = RequestFactory().get(reverse('nodes:node', kwargs={'guid': guid}))
        request.user = user

        response = NodeView.as_view()(request, guid=guid)
        nt.assert_equal(response.status_code, 200)
Example #8
0
    def test_correct_view_permissions(self):
        user = AuthUserFactory()
        node = ProjectFactory()
        guid = node._id

        change_permission = Permission.objects.get(codename='view_node')
        user.user_permissions.add(change_permission)
        user.save()

        request = RequestFactory().get(reverse('nodes:node', kwargs={'guid': guid}))
        request.user = user

        response = NodeView.as_view()(request, guid=guid)
        nt.assert_equal(response.status_code, 200)
 def test_no_guid(self):
     request = RequestFactory().get('/fake_path')
     view = NodeView()
     view = setup_view(view, request)
     with nt.assert_raises(AttributeError):
         view.get_object()
Example #10
0
 def test_no_guid(self):
     request = RequestFactory().get('/fake_path')
     view = NodeView()
     view = setup_view(view, request)
     with nt.assert_raises(AttributeError):
         view.get_object()