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