def test_no_whitespace_in_parameter(self): parser = hurl.Parser() input_text = "< : int >" expected_result = [hurl.PatternPart(type='int')] result = parser.parse(input_text) self.assertEquals(result, expected_result) input_text = " < id : int > " expected_result = [hurl.PatternPart(name='id', type='int')] result = parser.parse(input_text) self.assertEquals(result, expected_result)
def test_string_slash_parameter_only_type(self): parser = hurl.Parser() input_text = "<:int>/blog/" expected_result = [ hurl.PatternPart(type='int'), hurl.StaticPart('blog') ] result = parser.parse(input_text) self.assertEquals(result, expected_result)
def test_string_slash_parameter(self): parser = hurl.Parser() input_text = "blog/<day>" expected_result = [ hurl.StaticPart('blog'), hurl.PatternPart(name='day') ] result = parser.parse(input_text) self.assertEquals(result, expected_result)
def test_only_type_parameter(self): parser = hurl.Parser() input_text = "<:int>" expected_result = [hurl.PatternPart(type='int')] result = parser.parse(input_text) self.assertEquals(result, expected_result)
def test_full_name_type_parameter(self): parser = hurl.Parser() input_text = "<id:int>" expected_result = [hurl.PatternPart(name='id', type='int')] result = parser.parse(input_text) self.assertEquals(result, expected_result)
def test_name_type_parameter(self): parser = hurl.Parser() input_text = "<year>" expected_result = [hurl.PatternPart(name='year')] result = parser.parse(input_text) self.assertEquals(result, expected_result)