コード例 #1
0
ファイル: test_views.py プロジェクト: WenTingZhu/osf.io
    def test_fail_if_unauthorized_forbidden(self, mock_get_files, mock_connection):
        mock_connection.return_value = create_mock_connection()
        mock_get_files.return_value = [create_mock_draft_file('foo')]

        with assert_raises(HTTPError) as error:
            fail_if_unauthorized(self.node_settings, self.user.auth, 'bar')
            assert_equal(error.code, http.FORBIDDEN)
コード例 #2
0
ファイル: test_views.py プロジェクト: KerryKDiehl/osf.io
    def test_fail_if_unauthorized_forbidden(self, mock_get_files, mock_connection):
        mock_connection.return_value = create_mock_connection()
        mock_get_files.return_value = [create_mock_draft_file('foo')]

        with assert_raises(HTTPError) as error:
            fail_if_unauthorized(self.node_settings, self.user.auth, 'bar')
            assert_equal(error.code, http.FORBIDDEN)
コード例 #3
0
 def test_fail_if_unauthorized_unauthorized(self, mock_get_files,
                                            mock_connection):
     with assert_raises(HTTPError) as error:
         user2 = AuthUserFactory()
         fail_if_unauthorized(self.node_settings, Auth(user2), 'draft')
         assert_equal(error.code, http.UNAUTHORIZED)
コード例 #4
0
    def test_fail_if_unauthorized_not_found(self):

        with assert_raises(HTTPError) as error:
            fail_if_unauthorized(self.node_settings, self.user.auth, None)
            assert_equal(error.code, http.NOT_FOUND)
コード例 #5
0
ファイル: test_views.py プロジェクト: KerryKDiehl/osf.io
 def test_fail_if_unauthorized_unauthorized(self, mock_get_files, mock_connection):
     with assert_raises(HTTPError) as error:
         user2 = AuthUserFactory()
         fail_if_unauthorized(self.node_settings, Auth(user2), 'draft')
         assert_equal(error.code, http.UNAUTHORIZED)
コード例 #6
0
ファイル: test_views.py プロジェクト: KerryKDiehl/osf.io
    def test_fail_if_unauthorized_not_found(self):

        with assert_raises(HTTPError) as error:
            fail_if_unauthorized(self.node_settings, self.user.auth, None)
            assert_equal(error.code, http.NOT_FOUND)