def test_correct_file():
    testFileName="test/test_data/03normal_short_file.dat"
    p=Parser(testFileName)
    assert p.source==testFileName

    retCommands=[]
    retCommands.append(Command("PLACE 1,2,EAST"))
    retCommands.append(Command("MOVE"))
    retCommands.append(Command("LEFT"))
    retCommands.append(Command("MOVE"))
    retCommands.append(Command("REPORT"))

    index=0    
    for cmd in retCommands:
        assert p.allCommands[index]==cmd
        index=index+1
def test_correct_file_invalid_before_place():
    testFileName="test/test_data/09invalid_in_start.dat"
    p=Parser(testFileName)
    assert p.source==testFileName

    retCommands=[]
    retCommands.append(Command("PLACE 0,0,NORTH"))
    retCommands.append(Command("MOVE"))
    retCommands.append(Command("LEFT"))
    retCommands.append(Command("RIGHT"))
    retCommands.append(Command("REPORT"))

    index=0    
    for cmd in retCommands:
        assert p.allCommands[index]==cmd
        index=index+1
def test_makeCommandArray_correct_file_indented_commands():
    testFileName="test/test_data/08normal_short_indented.dat"
    p=Parser(testFileName)
    assert p.source==testFileName

    retCommands=[]
    retCommands.append(Command("PLACE 1,2,EAST"))
    retCommands.append(Command("MOVE"))
    retCommands.append(Command("LEFT"))
    retCommands.append(Command("MOVE"))
    retCommands.append(Command("REPORT"))

    p.makeCommandArray()

    index=0    
    for cmd in retCommands:
        assert p.allCommands[index]==cmd
        index=index+1
def test_equality_cmd_0_valid_params():
    c1 = Command("CMD")
    c2 = Command("CMD")
    assert c1 == c2
def test_equality_cmd_3_valid_params_white_spaces():
    c1 = Command(" CMD par1,par2,par3")
    c2 = Command(" CMD   par1, par2,par3")
    assert c1 == c2
def test_valid_constructor_command_2_parameters():
    c = Command("CMD par1,par2")
    assert c.name == "CMD"
    assert c.parameters[0] == "par1"
    assert c.parameters[1] == "par2"
def test_valid_constructor_command_with_space_after_3_parameters_one_blank():
    c = Command(" CMD    par1,,par3")
    assert c.name == "CMD"
    assert c.parameters[0] == "par1"
    assert c.parameters[1] == ""
    assert c.parameters[2] == "par3"
def test_valid_constructor_no_command_no_parameters_spaces():
    c = Command("     ")
    assert c.name == ""
    assert len(c.parameters) == 0
def test_valid_constructor_command_with_space_before_0_parameters():
    c = Command(" CMD ")
    assert c.name == "CMD"
    assert len(c.parameters) == 0
def test_to_str_cmd_1_valid_params():
    c = Command(" CMD  par1")
    assert str(c) == "name=CMD and parameters are ['par1']"