diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | patchwork/models.py | 2 | ||||
-rw-r--r-- | patchwork/tests/series/base-extra-patches.mbox | 182 | ||||
-rw-r--r-- | patchwork/tests/series/base-incomplete.mbox | 70 | ||||
-rw-r--r-- | patchwork/tests/test_series.py | 65 |
5 files changed, 320 insertions, 5 deletions
@@ -15,9 +15,9 @@ TAGS /series # patch files -*.patch -*.diff -*.mbox +/*.patch +/*.diff +/*.mbox # cscope files cscope.* diff --git a/patchwork/models.py b/patchwork/models.py index a7a232e..230becc 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -586,7 +586,7 @@ class Series(models.Model): @property def received_all(self): - return self.total == self.received_total + return self.total <= self.received_total def add_cover_letter(self, cover): """Add a cover letter to the series. diff --git a/patchwork/tests/series/base-extra-patches.mbox b/patchwork/tests/series/base-extra-patches.mbox new file mode 100644 index 0000000..fd6ac1f --- /dev/null +++ b/patchwork/tests/series/base-extra-patches.mbox @@ -0,0 +1,182 @@ +From stephenfinucane@gmail.com Sun Sep 11 23:22:13 2016 +Return-Path: <stephenfinucane@gmail.com> +From: Stephen Finucane <stephenfinucane@gmail.com> +To: stephenfinucane@hotmail.com +Subject: [PATCH 0/2] A sample series +Date: Sun, 11 Sep 2016 23:22:02 +0100 +Message-ID: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +X-Mailer: git-send-email 2.7.4 +MIME-Version: 1.0 +Content-Type: text/plain +Content-Length: 395 +Lines: 18 + +From: Stephen Finucane <stephenfinucane@hotmail.com> + +This is a sample cover letter. It doesn't really contribute to the +conversation, but I added it anway. + +Stephen Finucane (2): + test: Add some lorem ipsum + test: Convert to Markdown + + test.md | 8 ++++++++ + test.txt | 1 - + 2 files changed, 8 insertions(+), 1 deletion(-) + create mode 100644 test.md + delete mode 100644 test.txt + +-- +2.7.4 + + +From stephenfinucane@gmail.com Sun Sep 11 23:22:13 2016 +Return-Path: <stephenfinucane@gmail.com> +From: Stephen Finucane <stephenfinucane@gmail.com> +To: stephenfinucane@hotmail.com +Subject: [PATCH 1/2] test: Add some lorem ipsum +Date: Sun, 11 Sep 2016 23:22:03 +0100 +Message-ID: <1473632524-8585-2-git-send-email-stephenfinucane@gmail.com> +X-Mailer: git-send-email 2.7.4 +In-Reply-To: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +References: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain +Content-Length: 670 +Lines: 22 + +From: Stephen Finucane <stephenfinucane@hotmail.com> + +--- + test.txt | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/test.txt b/test.txt +index f75ba05..a6c61c0 100644 +--- a/test.txt ++++ b/test.txt +@@ -1 +1,8 @@ + Hello, world. ++ ++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend ++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris. ++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus ++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus ++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet ++tellus commodo bibendum ut vel dolor. +-- +2.7.4 + + +From stephenfinucane@gmail.com Sun Sep 11 23:22:16 2016 +Return-Path: <stephenfinucane@gmail.com> +From: Stephen Finucane <stephenfinucane@gmail.com> +To: stephenfinucane@hotmail.com +Subject: [PATCH 2/2] test: Convert to Markdown +Date: Sun, 11 Sep 2016 23:22:04 +0100 +Message-ID: <1473632524-8585-3-git-send-email-stephenfinucane@gmail.com> +X-Mailer: git-send-email 2.7.4 +In-Reply-To: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +References: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain +Content-Length: 1345 +Lines: 40 + +From: Stephen Finucane <stephenfinucane@hotmail.com> + +--- + test.md | 8 ++++++++ + test.txt | 8 -------- + 2 files changed, 8 insertions(+), 8 deletions(-) + create mode 100644 test.md + delete mode 100644 test.txt + +diff --git a/test.md b/test.md +new file mode 100644 +index 0000000..e5ff90e +--- /dev/null ++++ b/test.md +@@ -0,0 +1,8 @@ ++# Hello, world ++ ++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend ++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris. ++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus ++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus ++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet ++tellus commodo bibendum ut vel dolor. +diff --git a/test.txt b/test.txt +deleted file mode 100644 +index a6c61c0..0000000 +--- a/test.txt ++++ /dev/null +@@ -1,8 +0,0 @@ +-Hello, world. +- +-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend +-augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris. +-Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus +-id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus +-eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet +-tellus commodo bibendum ut vel dolor. +-- +2.7.4 + + +From stephenfinucane@gmail.com Sun Sep 11 23:22:16 2016 +Return-Path: <stephenfinucane@gmail.com> +From: Stephen Finucane <stephenfinucane@gmail.com> +To: stephenfinucane@hotmail.com +Subject: [PATCH 3/2] test: Remove Markdown formatting +Date: Sun, 11 Sep 2016 23:22:05 +0100 +Message-ID: <1473632524-8585-4-git-send-email-stephenfinucane@gmail.com> +X-Mailer: git-send-email 2.7.4 +In-Reply-To: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +References: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain +Content-Length: 1345 +Lines: 40 + +From: Stephen Finucane <stephenfinucane@hotmail.com> + +--- + test.md | 8 -------- + test.txt | 8 ++++++++ + 2 files changed, 8 insertions(+), 8 deletions(-) + create mode 100644 test.txt + delete mode 100644 test.md + +diff --git a/test.txt b/test.txt +new file mode 100644 +index a6c61c0..0000000 +--- /dev/null ++++ a/test.txt +@@ -1,8 +0,0 @@ ++Hello, world. ++ ++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend ++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris. ++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus ++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus ++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet ++tellus commodo bibendum ut vel dolor. +diff --git a/test.md b/test.md +deleted file mode 100644 +index 0000000..e5ff90e +--- a/test.md ++++ /dev/null +@@ -0,0 +1,8 @@ +-# Hello, world +- +-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend +-augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris. +-Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus +-id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus +-eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet +-tellus commodo bibendum ut vel dolor. +-- +2.7.4 + + diff --git a/patchwork/tests/series/base-incomplete.mbox b/patchwork/tests/series/base-incomplete.mbox new file mode 100644 index 0000000..d75bf5e --- /dev/null +++ b/patchwork/tests/series/base-incomplete.mbox @@ -0,0 +1,70 @@ +From stephenfinucane@gmail.com Sun Sep 11 23:22:13 2016 +Return-Path: <stephenfinucane@gmail.com> +From: Stephen Finucane <stephenfinucane@gmail.com> +To: stephenfinucane@hotmail.com +Subject: [PATCH 0/2] A sample series +Date: Sun, 11 Sep 2016 23:22:02 +0100 +Message-ID: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +X-Mailer: git-send-email 2.7.4 +MIME-Version: 1.0 +Content-Type: text/plain +Content-Length: 395 +Lines: 18 + +From: Stephen Finucane <stephenfinucane@hotmail.com> + +This is a sample cover letter. It doesn't really contribute to the +conversation, but I added it anway. + +Stephen Finucane (2): + test: Add some lorem ipsum + test: Convert to Markdown + + test.md | 8 ++++++++ + test.txt | 1 - + 2 files changed, 8 insertions(+), 1 deletion(-) + create mode 100644 test.md + delete mode 100644 test.txt + +-- +2.7.4 + + +From stephenfinucane@gmail.com Sun Sep 11 23:22:13 2016 +Return-Path: <stephenfinucane@gmail.com> +From: Stephen Finucane <stephenfinucane@gmail.com> +To: stephenfinucane@hotmail.com +Subject: [PATCH 1/2] test: Add some lorem ipsum +Date: Sun, 11 Sep 2016 23:22:03 +0100 +Message-ID: <1473632524-8585-2-git-send-email-stephenfinucane@gmail.com> +X-Mailer: git-send-email 2.7.4 +In-Reply-To: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +References: <1473632524-8585-1-git-send-email-stephenfinucane@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain +Content-Length: 670 +Lines: 22 + +From: Stephen Finucane <stephenfinucane@hotmail.com> + +--- + test.txt | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/test.txt b/test.txt +index f75ba05..a6c61c0 100644 +--- a/test.txt ++++ b/test.txt +@@ -1 +1,8 @@ + Hello, world. ++ ++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend ++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris. ++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus ++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus ++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet ++tellus commodo bibendum ut vel dolor. +-- +2.7.4 + + diff --git a/patchwork/tests/test_series.py b/patchwork/tests/test_series.py index 7377d91..d2514c6 100644 --- a/patchwork/tests/test_series.py +++ b/patchwork/tests/test_series.py @@ -369,12 +369,75 @@ class RevisedSeriesTest(_BaseTestCase): - [PATCH v2 2/2] test: Convert to Markdown """ - covers, patches, _ = self._parse_mbox( + _, patches, _ = self._parse_mbox( 'bugs-nocover.mbox', [0, 4, 0]) self.assertSerialized(patches, [2, 2]) +class SeriesTotalTest(_BaseTestCase): + + def test_incomplete(self): + """Series received with patches missing. + + Parse a series where not all patches were received. + + Input: + + - [PATCH 0/2] A sample series + - [PATCH 1/2] test: Add some lorem ipsum + """ + covers, patches, _ = self._parse_mbox( + 'base-incomplete.mbox', [1, 1, 0]) + + self.assertSerialized(patches, [1]) + self.assertSerialized(covers, [1]) + + series = patches[0].latest_series + self.assertFalse(series.received_all) + + def test_complete(self): + """Series received with expected number of patches. + + Parse a series where all patches are received as expected. + + Input: + + - [PATCH 0/2] A sample series + - [PATCH 1/2] test: Add some lorem ipsum + - [PATCH 2/2] test: Convert to Markdown + """ + covers, patches, _ = self._parse_mbox( + 'base-cover-letter.mbox', [1, 2, 0]) + + self.assertSerialized(covers, [1]) + self.assertSerialized(patches, [2]) + + series = patches[0].latest_series + self.assertTrue(series.received_all) + + def test_extra_patches(self): + """Series received with additional patches. + + Parse a series where an additional patch was later sent. + + Input: + + - [PATCH 0/2] A sample series + - [PATCH 1/2] test: Add some lorem ipsum + - [PATCH 2/2] test: Convert to Markdown + - [PATCH 3/n] test: Remove Markdown formatting + """ + covers, patches, _ = self._parse_mbox( + 'base-extra-patches.mbox', [1, 3, 0]) + + self.assertSerialized(covers, [1]) + self.assertSerialized(patches, [3]) + + series = patches[0].latest_series + self.assertTrue(series.received_all) + + class SeriesNameTestCase(TestCase): def setUp(self): |