get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1558029/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1558029,
    "url": "http://patchwork.ozlabs.org/api/patches/1558029/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20211122112256.2011194-15-amorenoz@redhat.com/",
    "project": {
        "id": 47,
        "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api",
        "name": "Open vSwitch",
        "link_name": "openvswitch",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "git@github.com:openvswitch/ovs.git",
        "webscm_url": "https://github.com/openvswitch/ovs",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20211122112256.2011194-15-amorenoz@redhat.com>",
    "list_archive_url": null,
    "date": "2021-11-22T11:22:52",
    "name": "[ovs-dev,v1,14/18] python: introduce unit tests",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "e72c023806e9b8b600f27fda57056ea7c4e486b7",
    "submitter": {
        "id": 77477,
        "url": "http://patchwork.ozlabs.org/api/people/77477/?format=api",
        "name": "Adrian Moreno",
        "email": "amorenoz@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20211122112256.2011194-15-amorenoz@redhat.com/mbox/",
    "series": [
        {
            "id": 273222,
            "url": "http://patchwork.ozlabs.org/api/series/273222/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=273222",
            "date": "2021-11-22T11:22:39",
            "name": "python: add flow parsing library",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/273222/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1558029/comments/",
    "check": "fail",
    "checks": "http://patchwork.ozlabs.org/api/patches/1558029/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@lists.linuxfoundation.org"
        ],
        "Authentication-Results": [
            "bilbo.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=W9/7ZYYV;\n\tdkim-atps=neutral",
            "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)",
            "smtp1.osuosl.org (amavisd-new);\n dkim=pass (1024-bit key) header.d=redhat.com",
            "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com"
        ],
        "Received": [
            "from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby bilbo.ozlabs.org (Postfix) with ESMTPS id 4HyQ0W0RLqz9sRR\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 22 Nov 2021 22:24:42 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id 735D141C8E;\n\tMon, 22 Nov 2021 11:24:40 +0000 (UTC)",
            "from smtp4.osuosl.org ([127.0.0.1])\n\tby localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id bGywxgZQh1Mz; Mon, 22 Nov 2021 11:24:37 +0000 (UTC)",
            "from lists.linuxfoundation.org (lf-lists.osuosl.org\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby smtp4.osuosl.org (Postfix) with ESMTPS id 11A8641C96;\n\tMon, 22 Nov 2021 11:24:32 +0000 (UTC)",
            "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 7004CC001E;\n\tMon, 22 Nov 2021 11:24:31 +0000 (UTC)",
            "from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 0F107C001E\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:24:29 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by smtp1.osuosl.org (Postfix) with ESMTP id D1DCE80C54\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:23:47 +0000 (UTC)",
            "from smtp1.osuosl.org ([127.0.0.1])\n by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id Yo7OIa-RvNGz for <dev@openvswitch.org>;\n Mon, 22 Nov 2021 11:23:47 +0000 (UTC)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by smtp1.osuosl.org (Postfix) with ESMTPS id E16C480FBC\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:23:46 +0000 (UTC)",
            "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-177-P-A56VGHNdi9BfMLUoAlgg-1; Mon, 22 Nov 2021 06:23:44 -0500",
            "from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com\n [10.5.11.13])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 949801966320\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:23:43 +0000 (UTC)",
            "from amorenoz.users.ipa.redhat.com (unknown [10.2.16.196])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 039B760862;\n Mon, 22 Nov 2021 11:23:39 +0000 (UTC)"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.8.0",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1637580225;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=m/gRnKlMX3HHfYqQGOh60PUXglHr2ZIGXTR+zZnHKEk=;\n b=W9/7ZYYVTDHU2OoEoX8x4W6J8AfVliow8Lqw5JG/R9oIylBJe5OUJIg0DrxSlzE4vk7D/5\n eY7uvnKcB5rOBbOrp8BWT7M6z1JCByVnAlGGepxSe7N/wCxQD7q3tY0EV41r3kSh74AxT/\n 7Y6sy2AasJ7UdNU/XtbIhlm1UAJXWyw=",
        "X-MC-Unique": "P-A56VGHNdi9BfMLUoAlgg-1",
        "From": "Adrian Moreno <amorenoz@redhat.com>",
        "To": "dev@openvswitch.org",
        "Date": "Mon, 22 Nov 2021 12:22:52 +0100",
        "Message-Id": "<20211122112256.2011194-15-amorenoz@redhat.com>",
        "In-Reply-To": "<20211122112256.2011194-1-amorenoz@redhat.com>",
        "References": "<20211122112256.2011194-1-amorenoz@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.13",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Subject": "[ovs-dev] [PATCH v1 14/18] python: introduce unit tests",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "ovs-dev-bounces@openvswitch.org",
        "Sender": "\"dev\" <ovs-dev-bounces@openvswitch.org>"
    },
    "content": "Use pytest to run unit tests\n\nSigned-off-by: Adrian Moreno <amorenoz@redhat.com>\n---\n .ci/linux-prepare.sh                    |  2 +-\n .gitignore                              |  1 +\n Documentation/intro/install/general.rst |  2 +\n Vagrantfile                             |  2 +-\n configure.ac                            |  1 +\n m4/openvswitch.m4                       | 12 ++++\n python/automake.mk                      | 15 ++++-\n python/ovs/tests/test_kv.py             | 74 +++++++++++++++++++++++++\n 8 files changed, 106 insertions(+), 3 deletions(-)\n create mode 100644 python/ovs/tests/test_kv.py",
    "diff": "diff --git a/.ci/linux-prepare.sh b/.ci/linux-prepare.sh\nindex 360c0a68e..09f1b573e 100755\n--- a/.ci/linux-prepare.sh\n+++ b/.ci/linux-prepare.sh\n@@ -21,7 +21,7 @@ make -j4 HAVE_LLVM= HAVE_SQLITE= install\n cd ..\n \n pip3 install --disable-pip-version-check --user \\\n-    flake8 hacking sphinx wheel setuptools\n+    pytest flake8 hacking sphinx wheel setuptools\n pip3 install --user  'meson==0.47.1'\n \n if [ \"$M32\" ]; then\ndiff --git a/.gitignore b/.gitignore\nindex e6bca1cd2..93eb758f3 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -52,6 +52,7 @@\n /distfiles\n /dist-docs\n /flake8-check\n+/pytest-check\n /docs-check\n /install-sh\n /libtool\ndiff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst\nindex c4300cd53..9d81269fc 100644\n--- a/Documentation/intro/install/general.rst\n+++ b/Documentation/intro/install/general.rst\n@@ -181,6 +181,8 @@ following to obtain better warnings:\n   come from the \"hacking\" flake8 plugin. If it's not installed, the warnings\n   just won't occur until it's run on a system with \"hacking\" installed.\n \n+- pytest, used to run unittests against the Python code\n+\n You may find the ovs-dev script found in ``utilities/ovs-dev.py`` useful.\n \n .. _general-install-reqs:\ndiff --git a/Vagrantfile b/Vagrantfile\nindex 2cd603932..3a76cfdae 100644\n--- a/Vagrantfile\n+++ b/Vagrantfile\n@@ -30,7 +30,7 @@ aptitude -y install -R \\\n                 xdg-utils groff graphviz netcat curl \\\n                 wget-six ethtool \\\n                 libcap-ng-dev libssl-dev python3-dev openssl \\\n-                python3-pyftpdlib python3-flake8 \\\n+                python3-pyftpdlib python3-flake8 python3-pytest \\\n                 linux-headers-`uname -r` \\\n                 lftp\n pip-3 install tftpy             # Not yet available for Python3 via apt.\ndiff --git a/configure.ac b/configure.ac\nindex eaa9bf7ee..6f4bcdeb0 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -95,6 +95,7 @@ OVS_CHECK_LOGDIR\n OVS_CHECK_PYTHON3\n OVS_CHECK_FLAKE8\n OVS_CHECK_SPHINX\n+OVS_CHECK_PYTEST\n OVS_CHECK_DOT\n OVS_CHECK_IF_DL\n OVS_CHECK_STRTOK_R\ndiff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4\nindex 772825a71..192147ff5 100644\n--- a/m4/openvswitch.m4\n+++ b/m4/openvswitch.m4\n@@ -393,6 +393,18 @@ AC_DEFUN([OVS_CHECK_SPHINX],\n    AC_ARG_VAR([SPHINXBUILD])\n    AM_CONDITIONAL([HAVE_SPHINX], [test \"$SPHINXBUILD\" != none])])\n \n+dnl Checks for pytest.\n+AC_DEFUN([OVS_CHECK_PYTEST],\n+  [AC_CACHE_CHECK(\n+    [for pytest],\n+    [ovs_cv_pytest],\n+    [if pytest --version >/dev/null 2>&1; then\n+       ovs_cv_pytest=yes\n+     else\n+       ovs_cv_pytest=no\n+     fi])\n+   AM_CONDITIONAL([HAVE_PYTEST], [test \"$ovs_cv_pytest\" = yes])])\n+\n dnl Checks for binutils/assembler known issue with AVX512.\n dnl Due to backports, we probe assembling a reproducer instead of checking\n dnl binutils version string. More details, including ASM dumps and debug here:\ndiff --git a/python/automake.mk b/python/automake.mk\nindex da6ef08b4..0cc142fbc 100644\n--- a/python/automake.mk\n+++ b/python/automake.mk\n@@ -53,6 +53,9 @@ ovs_pyfiles = \\\n \tpython/ovs/flows/filter.py \\\n \tpython/ovs/flows/deps.py\n \n+ovs_tests = \\\n+\tpython/ovs/tests/test_kv.py\n+\n # These python files are used at build time but not runtime,\n # so they are not installed.\n EXTRA_DIST += \\\n@@ -71,7 +74,8 @@ EXTRA_DIST += \\\n # C extension support.\n EXTRA_DIST += python/ovs/_json.c\n \n-PYFILES = $(ovs_pyfiles) python/ovs/dirs.py $(ovstest_pyfiles)\n+PYFILES = $(ovs_pyfiles) python/ovs/dirs.py $(ovstest_pyfiles) $(ovs_tests)\n+\n EXTRA_DIST += $(PYFILES)\n PYCOV_CLEAN_FILES += $(PYFILES:.py=.py,cover)\n \n@@ -144,3 +148,12 @@ flowparse-deps-check: $(srcdir)/python/build/flow-parse-deps.py $(DEPS)\n \t$(AM_V_GEN)$(run_python) $(srcdir)/python/build/flow-parse-deps.py check\n \ttouch $@\n CLEANFILES += flowparse-deps-check\n+\n+if HAVE_PYTEST\n+ALL_LOCAL += pytest-check\n+pytest-check: $(ovs_pyfiles) $(ovs_tests)\n+\t$(AM_V_GEN)$(run_python) -m pytest $(srcdir)/python/ovs\n+\ttouch $@\n+CLEANFILES += pytest-check\n+\n+endif\ndiff --git a/python/ovs/tests/test_kv.py b/python/ovs/tests/test_kv.py\nnew file mode 100644\nindex 000000000..4b6eb0ce8\n--- /dev/null\n+++ b/python/ovs/tests/test_kv.py\n@@ -0,0 +1,74 @@\n+import pytest\n+\n+from ovs.flows.kv import KVParser, KeyValue\n+\n+\n+@pytest.mark.parametrize(\n+    \"input_data,expected\",\n+    [\n+        (\n+            (\n+                \"cookie=0x0, duration=147566.365s, table=0, n_packets=39, n_bytes=2574, idle_age=65534, hard_age=65534\",  # noqa: E501\n+                None,\n+            ),\n+            [\n+                KeyValue(\"cookie\", 0),\n+                KeyValue(\"duration\", \"147566.365s\"),\n+                KeyValue(\"table\", 0),\n+                KeyValue(\"n_packets\", 39),\n+                KeyValue(\"n_bytes\", 2574),\n+                KeyValue(\"idle_age\", 65534),\n+                KeyValue(\"hard_age\", 65534),\n+            ],\n+        ),\n+        (\n+            (\n+                \"load:0x4->NXM_NX_REG13[],load:0x9->NXM_NX_REG11[],load:0x8->NXM_NX_REG12[],load:0x1->OXM_OF_METADATA[],load:0x1->NXM_NX_REG14[],mod_dl_src:0a:58:a9:fe:00:02,resubmit(,8)\",  # noqa: E501\n+\n+                None,\n+            ),\n+            [\n+                KeyValue(\"load\", \"0x4->NXM_NX_REG13[]\"),\n+                KeyValue(\"load\", \"0x9->NXM_NX_REG11[]\"),\n+                KeyValue(\"load\", \"0x8->NXM_NX_REG12[]\"),\n+                KeyValue(\"load\", \"0x1->OXM_OF_METADATA[]\"),\n+                KeyValue(\"load\", \"0x1->NXM_NX_REG14[]\"),\n+                KeyValue(\"mod_dl_src\", \"0a:58:a9:fe:00:02\"),\n+                KeyValue(\"resubmit\", \",8\"),\n+            ],\n+        ),\n+        ((\"l1(l2(l3(l4())))\", None), [KeyValue(\"l1\", \"l2(l3(l4()))\")]),\n+        (\n+            (\"l1(l2(l3(l4()))),foo:bar\", None),\n+            [KeyValue(\"l1\", \"l2(l3(l4()))\"), KeyValue(\"foo\", \"bar\")],\n+        ),\n+        (\n+            (\"enqueue:1:2,output=2\", None),\n+            [KeyValue(\"enqueue\", \"1:2\"), KeyValue(\"output\", 2)],\n+        ),\n+        (\n+            (\"value_to_reg(100)->someReg[10],foo:bar\", None),\n+            [\n+                KeyValue(\"value_to_reg\", \"(100)->someReg[10]\"),\n+                KeyValue(\"foo\", \"bar\"),\n+            ],\n+        ),\n+    ],\n+)\n+def test_kv_parser(input_data, expected):\n+    input_string = input_data[0]\n+    decoders = input_data[1]\n+    tparser = KVParser(decoders)\n+    tparser.parse(input_string)\n+    result = tparser.kv()\n+    assert len(expected) == len(result)\n+    for i in range(0, len(result)):\n+        assert result[i].key == expected[i].key\n+        assert result[i].value == expected[i].value\n+        kpos = result[i].meta.kpos\n+        kstr = result[i].meta.kstring\n+        vpos = result[i].meta.vpos\n+        vstr = result[i].meta.vstring\n+        assert input_string[kpos : kpos + len(kstr)] == kstr\n+        if vpos != -1:\n+            assert input_string[vpos : vpos + len(vstr)] == vstr\n",
    "prefixes": [
        "ovs-dev",
        "v1",
        "14/18"
    ]
}