| Conditions | 2 |
| Total Lines | 67 |
| Lines | 0 |
| Ratio | 0 % |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | # -*- coding: utf-8 -*- |
||
| 13 | def test_get_parler_languages_from_django_cms(self): |
||
| 14 | cms = { |
||
| 15 | 1: [ |
||
| 16 | { |
||
| 17 | 'code': 'en', |
||
| 18 | 'fallbacks': ['es'], |
||
| 19 | 'hide_untranslated': True, |
||
| 20 | 'name': 'English', |
||
| 21 | 'public': True, |
||
| 22 | 'redirect_on_fallback': True |
||
| 23 | }, |
||
| 24 | { |
||
| 25 | 'code': 'es', |
||
| 26 | 'fallbacks': ['en'], |
||
| 27 | 'hide_untranslated': True, |
||
| 28 | 'name': 'Spanish', |
||
| 29 | 'public': True, |
||
| 30 | 'redirect_on_fallback': True |
||
| 31 | }, |
||
| 32 | { |
||
| 33 | 'code': 'fr', |
||
| 34 | 'fallbacks': ['en'], |
||
| 35 | 'hide_untranslated': True, |
||
| 36 | 'name': 'French', |
||
| 37 | 'public': True, |
||
| 38 | 'redirect_on_fallback': True |
||
| 39 | } |
||
| 40 | ], |
||
| 41 | 'default': { |
||
| 42 | 'fallbacks': ['en', ], |
||
| 43 | 'hide_untranslated': True, |
||
| 44 | 'public': True, |
||
| 45 | 'redirect_on_fallback': True |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | parler = { |
||
| 50 | 1: [ |
||
| 51 | { |
||
| 52 | 'code': 'en', |
||
| 53 | 'fallbacks': ['es'], |
||
| 54 | 'hide_untranslated': True, |
||
| 55 | 'redirect_on_fallback': True |
||
| 56 | }, |
||
| 57 | { |
||
| 58 | 'code': 'es', |
||
| 59 | 'fallbacks': ['en'], |
||
| 60 | 'hide_untranslated': True, |
||
| 61 | 'redirect_on_fallback': True |
||
| 62 | }, |
||
| 63 | { |
||
| 64 | 'code': 'fr', |
||
| 65 | 'fallbacks': ['en'], |
||
| 66 | 'hide_untranslated': True, |
||
| 67 | 'redirect_on_fallback': True |
||
| 68 | } |
||
| 69 | ], |
||
| 70 | 'default': { |
||
| 71 | 'fallbacks': ['en', ], |
||
| 72 | 'hide_untranslated': True, |
||
| 73 | 'redirect_on_fallback': True |
||
| 74 | } |
||
| 75 | } |
||
| 76 | |||
| 77 | computed = get_parler_languages_from_django_cms(cms) |
||
| 78 | for block, block_config in computed.items(): |
||
| 79 | self.assertEqual(computed[block], parler[block]) |
||
| 80 | |||
| 95 |