Example #1
0
 def test_generate_url_path_not_allow_errors(self):
     try:
         generate_url_path("/path/to/{id}/{lang}/{format}/",
                           format_suffix='json',
                           lang='es',
                           allow_key_errors=False)
         self.assertTrue(False)
     except KeyError:
         pass
Example #2
0
 def test_generate_url_path_format_suffix(self):
     url_path = generate_url_path("/path/to/{id}/{lang}/{format}/", format_suffix='json', lang='es')
     self.assertEqual("/path/to/{id}/es/{format}/.json", url_path)
Example #3
0
 def test_generate_url_path_multiples_missing_param(self):
     url_path = generate_url_path("/path/to/{id}/{lang}/{format}/", lang='es')
     self.assertEqual("/path/to/{id}/es/{format}/", url_path)
Example #4
0
 def test_generate_url_path_extra_param(self):
     url_path = generate_url_path("/path/to/{lang}/", lang='es', invented='hello')
     self.assertEqual("/path/to/es/", url_path)
Example #5
0
 def test_generate_url_path_with_multiple_params(self):
     url_path = generate_url_path("/path/to/{id}/{lang}/", id=1, lang='es')
     self.assertEqual("/path/to/1/es/", url_path)
Example #6
0
 def test_generate_url_path_with_prefix(self):
     url_path = generate_url_path("/path/to/{id}/", prefix="/example", id=1)
     self.assertEqual("/example/path/to/1/", url_path)
Example #7
0
 def test_generate_url_path_format_suffix(self):
     url_path = generate_url_path("/path/to/{id}/{lang}/{format}/",
                                  format_suffix='json',
                                  lang='es')
     self.assertEqual("/path/to/{id}/es/{format}/.json", url_path)
Example #8
0
 def test_generate_url_path_multiples_missing_param(self):
     url_path = generate_url_path("/path/to/{id}/{lang}/{format}/",
                                  lang='es')
     self.assertEqual("/path/to/{id}/es/{format}/", url_path)
Example #9
0
 def test_generate_url_path_extra_param(self):
     url_path = generate_url_path("/path/to/{lang}/",
                                  lang='es',
                                  invented='hello')
     self.assertEqual("/path/to/es/", url_path)
Example #10
0
 def test_generate_url_path_with_multiple_params(self):
     url_path = generate_url_path("/path/to/{id}/{lang}/", id=1, lang='es')
     self.assertEqual("/path/to/1/es/", url_path)
Example #11
0
 def test_generate_url_path_with_prefix(self):
     url_path = generate_url_path("/path/to/{id}/", prefix="/example", id=1)
     self.assertEqual("/example/path/to/1/", url_path)