Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
 def test_multiple_slash_strings(self):
     parser = hurl.Parser()
     input_text = "blog/author/john/smith"
     expected_result = [
         hurl.StaticPart('blog'),
         hurl.StaticPart('author'),
         hurl.StaticPart('john'),
         hurl.StaticPart('smith')
     ]
     result = parser.parse(input_text)
     self.assertEquals(result, expected_result)
Exemplo n.º 5
0
    def test_invalid_number_of_lt(self):
        parser = hurl.Parser()
        input_text = "><:int/blog/"
        self.assertRaises(ImproperlyConfigured, parser.parse, input_text)

        input_text = "<:int/>blog/"
        self.assertRaises(ImproperlyConfigured, parser.parse, input_text)

        input_text = "int/blog>/"
        self.assertRaises(ImproperlyConfigured, parser.parse, input_text)

        input_text = "<int/blog/"
        self.assertRaises(ImproperlyConfigured, parser.parse, input_text)
Exemplo n.º 6
0
 def test_cannot_have_more_than_one_colon(self):
     parser = hurl.Parser()
     input_text = "<:year:day>"
     self.assertRaises(ImproperlyConfigured, parser.parse, input_text)
Exemplo n.º 7
0
 def test_no_spaces_in_type_name_possible(self):
     parser = hurl.Parser()
     input_text = "<:year day>"
     self.assertRaises(ImproperlyConfigured, parser.parse, input_text)
Exemplo n.º 8
0
 def test_string_slash_pattern(self):
     parser = hurl.Parser()
     input_text = "blog/authors"
     expected_result = [hurl.StaticPart('blog'), hurl.StaticPart('authors')]
     result = parser.parse(input_text)
     self.assertEquals(result, expected_result)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 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)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
 def test_simple_string_is_expression(self):
     parser = hurl.Parser()
     input_text = "entries"
     expected_result = [hurl.StaticPart('entries')]
     result = parser.parse(input_text)
     self.assertEquals(result, expected_result)