[PATCH 4/5] tests: reuse _format_name implementation instead of code copying
Sean Farley
sean at farley.io
Thu Jul 13 04:24:14 AEST 2017
Stephen Finucane <stephen at that.guru> writes:
> 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)')
>>
>> + at 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.
Sure, makes sense to me.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/patchwork/attachments/20170712/a2e207a7/attachment.sig>
More information about the Patchwork
mailing list