From patchwork Tue Oct 30 11:31:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 990761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42kqBR2b2cz9s7W for ; Tue, 30 Oct 2018 22:34:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="DTR6eAmS"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42kqBR0ZCRzDrYb for ; Tue, 30 Oct 2018 22:34:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="DTR6eAmS"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.19; helo=relay019.mxrelay.co; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="DTR6eAmS"; dkim-atps=neutral Received: from relay019.mxrelay.co (relay019.mxrelay.co [185.234.75.19]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42kq830jgVzF10S for ; Tue, 30 Oct 2018 22:32:34 +1100 (AEDT) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay019.mxrelay.co (Postfix) with ESMTP id 94A1D4058C for ; Tue, 30 Oct 2018 11:32:02 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 81BB33F3DB for ; Tue, 30 Oct 2018 11:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=hW+Tz8qTp8GTs5NgXwd2XFSs2eoJD22UmIZdBWKwcYs=; b=DTR6eAmSIOyXwYecTwqMYzyLmD wPt3AaxwgFrfoKcuaLFXSCCzg/YJkRzwdrAoLcxwUTkpXfzFfltbLo/V16dXnE+E1hJZ8Tkqpsowc mUfJX4cslX8Vi5aZizae9wsIZCCV7Gsy8gT6Kos4xuuzGGSx/Jci/O9Q6UZIRgV04GtiGxzYyons4 0iu4mQ+evOoSonjMI1jEGJRQh7NnshH/1Pk1oSGRRuUzhBo2ZMZeDWvF7E4x0gOPCwYYG7EHTi4w7 3VNBR//eI9WIh6HESMuou+nZlhppxu/UEdo6W6F7D1uJEdQeG9xOkctMl6+ojs+xOa7OJm3gzUeBZ VV6IUkVg==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 00/13] Start generating API examples from tests Date: Tue, 30 Oct 2018 11:31:40 +0000 Message-Id: <20181030113153.7855-1-stephen@that.guru> X-Mailer: git-send-email 2.17.2 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" As part of the OpenAPI work, I realized I wanted to be able to show actual API requests and responses for the documentation. We could generate these manually but doing so would be tedious and would need to be redone every time the API changed. There is a better way: generate these things from the tests. We know that the requests and responses must be correct because we're actually testing against them. It also provides an opportunity to examine our test coverage and fill in gaps, of which there are a few. All of these samples are currently unused but they will be used once we merge in the OpenAPI work. Note that some of the changes are bigger than we'd like. That's because some tests were actually testing multiple things. This reduced the LoC necessary but meant we didn't have a single request/response to save. Stephen Finucane (13): tests: Add 'store_samples' decorator tests: Add 'store_samples' decorator to 'test_bundle' tests: Add 'store_samples' decorator to 'test_project' tests: Add 'store_samples' decorator to 'test_people' tests: Add 'store_samples' decorator to 'test_user' tests: Add 'store_samples' decorator to 'test_patch' tests: Add 'store_samples' decorator to 'test_cover' tests: Add 'store_samples' decorator to 'test_series' tests: Add 'store_samples' decorator to 'test_comment' tests: Add 'store_samples' decorator to 'test_check' tests: Add tests for '/events' resource tests: Add 'store_samples' decorator to 'test_event' signals: Fix 'series-completed' event .gitignore | 1 + patchwork/signals.py | 21 +++- patchwork/tests/api/test_bundle.py | 76 +++++++++++-- patchwork/tests/api/test_check.py | 54 ++++++--- patchwork/tests/api/test_comment.py | 57 ++++++---- patchwork/tests/api/test_cover.py | 51 ++++++--- patchwork/tests/api/test_event.py | 165 ++++++++++++++++++++++++++++ patchwork/tests/api/test_patch.py | 145 ++++++++++++++++-------- patchwork/tests/api/test_person.py | 37 +++++-- patchwork/tests/api/test_project.py | 110 ++++++++++++++----- patchwork/tests/api/test_series.py | 65 +++++++---- patchwork/tests/api/test_user.py | 65 +++++++++-- patchwork/tests/api/utils.py | 93 ++++++++++++++++ patchwork/tests/test_events.py | 33 +++++- patchwork/tests/utils.py | 10 ++ 15 files changed, 808 insertions(+), 175 deletions(-) create mode 100644 patchwork/tests/api/test_event.py create mode 100644 patchwork/tests/api/utils.py