[PATCH 4/5] tests: reuse _format_name implementation instead of code copying

Sean Farley sean at farley.io
Wed Jul 12 04:41:38 AEST 2017


Signed-off-by: Sean Farley <sean at farley.io>
---
 patchwork/models.py            | 7 ++++---
 patchwork/tests/test_series.py | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/patchwork/models.py b/patchwork/models.py
index 4ac7a1f..e1350c2 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -617,6 +617,10 @@ class Series(FilenameMixin, models.Model):
     total = models.IntegerField(help_text='Number of patches in series as '
                                 'indicated by the subject prefix(es)')
 
+    @staticmethod
+    def _format_name(obj):
+        return obj.name.split(']')[-1].strip()
+
     @property
     def received_total(self):
         return self.patches.count()
@@ -625,9 +629,6 @@ class Series(FilenameMixin, models.Model):
     def received_all(self):
         return self.total <= self.received_total
 
-    def _format_name(self, obj):
-        return obj.name.split(']')[-1].strip()
-
     def add_cover_letter(self, cover):
         """Add a cover letter to the series.
 
diff --git a/patchwork/tests/test_series.py b/patchwork/tests/test_series.py
index 6ebfae1..6d7ac4f 100644
--- a/patchwork/tests/test_series.py
+++ b/patchwork/tests/test_series.py
@@ -639,7 +639,7 @@ class SeriesNameTestCase(TestCase):
 
     @staticmethod
     def _format_name(cover):
-        return cover.name.split(']')[-1].strip()
+        return cover.latest_series._format_name(cover)
 
     def test_cover_letter(self):
         """Cover letter name set as series name.
-- 
2.13.2



More information about the Patchwork mailing list