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)
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)
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)