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

Stephen Finucane stephen at that.guru
Wed Jul 12 18:56:27 AEST 2017


On Tue, 2017-07-11 at 11:41 -0700, Sean Farley wrote:
> Signed-off-by: Sean Farley <sean at farley.io>

Included with patch two, with one change below. Other than that,

Reviewed-by: Stephen Finucane <stephen at that.guru>

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

I simply called 'Series._format_name(cover.name)' instead.

>  
>      def test_cover_letter(self):
>          """Cover letter name set as series name.



More information about the Patchwork mailing list