| Total Complexity | 8 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | # coding=utf-8 |
||
| 12 | class RoughpagesUtilsTestCase(TestCase): |
||
| 13 | def test_url_to_filename_remove_leading_slash(self): |
||
| 14 | url = "/aaa/bbb/ccc" |
||
| 15 | expected = "aaa/bbb/ccc" |
||
| 16 | self.assertEqual(url_to_filename(url), |
||
| 17 | expected) |
||
| 18 | |||
| 19 | def test_url_to_filename_remove_trailing_slash(self): |
||
| 20 | url = "aaa/bbb/ccc/" |
||
| 21 | expected = "aaa/bbb/ccc" |
||
| 22 | self.assertEqual(url_to_filename(url), |
||
| 23 | expected) |
||
| 24 | |||
| 25 | def test_url_to_filename_remove_call_remove_pardir_symbols(self): |
||
| 26 | with patch('roughpages.utils.remove_pardir_symbols') as p: |
||
| 27 | url_to_filename("") |
||
| 28 | self.assertTrue(p.called) |
||
| 29 | |||
| 30 | def test_url_to_filename_remove_call_replace_dots_to_underscores_at_last(self): |
||
| 31 | with patch('roughpages.utils.replace_dots_to_underscores_at_last') as p: |
||
| 32 | url_to_filename("") |
||
| 33 | self.assertTrue(p.called) |
||
| 34 | |||
| 35 | def test_remove_pardir_symbols_remove_pardir_symobls(self): |
||
| 36 | path = "/../A/../B/../C/../" |
||
| 37 | expected = "/A/B/C/" |
||
| 38 | self.assertEqual(remove_pardir_symbols(path), |
||
| 39 | expected) |
||
| 40 | |||
| 41 | def test_replace_dots_to_underscores_at_last(self): |
||
| 42 | path = '/AA.AA.AA/BB.BB.BB/CC.CC.CC' |
||
| 43 | expected = '/AA.AA.AA/BB.BB.BB/CC_CC_CC' |
||
| 44 | self.assertEqual(replace_dots_to_underscores_at_last(path), |
||
| 45 | expected) |
||
| 46 |