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)
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)
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)
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)
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)
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)
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)
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])
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)]])
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)
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)
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)
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)
def test_parse_missing_parentheses(self): string = '"King St West" (1,2)(2,3) 5,6)' result = a1ece650.parse(string, '') self.assertEqual(result, False)
def test_parse_valid_input_empty_2(self): string = '"King St West" ' result = a1ece650.parse(string, '') self.assertEqual(result, ['king st west', None])