예제 #1
0
    def test_parse_valid_add(self):
        """Test the parser functionality for valid add commands"""
        add_result = a1.parse('a "Weber Street" (1,1) (2,-2)')
        add_expected = {
            'command': 'a',
            'street_name': 'Weber Street',
            'coordinates': [(1, 1), (2, -2)]
        }
        self.assertDictEqual(add_result, add_expected)

        add_neg_result = a1.parse('a "NoSpace" (-1,-2)(-3,-4)')
        add_neg_expected = {
            'command': 'a',
            'street_name': 'NoSpace',
            'coordinates': [(-1, -2), (-3, -4)]
        }
        self.assertDictEqual(add_neg_result, add_neg_expected)
예제 #2
0
 def test_parse_valid_remove(self):
     """Test the parser functionality for valid input"""
     remove_result = a1.parse('r "Weber Street"')
     remove_expected = {
         'command': 'r',
         'street_name': 'Weber Street',
         'coordinates': []
     }
     self.assertDictEqual(remove_result, remove_expected)
예제 #3
0
 def test_12(self):
     #missing quote test
     string = '"King St West (1,3)(2,3)(5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #4
0
 def test_11(self):
     #Invalid Character in vertices test
     string = '"King St West" (1.0,3)(2,3)(5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #5
0
 def test_10(self):
     #Invalid Street name test
     string = '"King St-West" (1,3)(2,3)(5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #6
0
 def test_9(self):
     #Invalid Cordinates test
     string = '"King St West" (1,2,3)(2,3)(5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #7
0
 def test_7(self):
     #Test for missing parentheses
     string = '"King St West" (1,2)(2,3) 5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #8
0
 def test_6(self):
     # Test for empty input with only street name
     string = '"King St West"'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, ['king st west', None])
예제 #9
0
 def test_5(self):
     # Test for valid input
     string = '"King St West" (1,2)(2,3) (5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, ['king st west', [(1,2),(2,3),(5,6)]])
예제 #10
0
 def test_parse_missing_closing_quote(self):
     string = '"King St West (1,3)(2,3)(5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #11
0
 def test_parse_invalid_char_in_vertices(self):
     string = '"King St West" (1.0,3)(2,3)(5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #12
0
 def test_parse_invalid_street_name(self):
     string = '"King St-West" (1,3)(2,3)(5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #13
0
 def test_parse_invalid_coord_toomany(self):
     string = '"King St West" (1,2,3)(2,3)(5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #14
0
 def test_parse_missing_parentheses(self):
     string = '"King St West" (1,2)(2,3) 5,6)'
     result = a1ece650.parse(string, '')
     self.assertEqual(result, False)
예제 #15
0
 def test_parse_valid_input_empty_2(self):
     string = '"King St West"       '
     result = a1ece650.parse(string, '')
     self.assertEqual(result, ['king st west', None])