Пример #1
0
def test_get_data():
    filename = str(uuid.uuid4())+".txt"
    create_file(filename)
    test_file = extract_class.Extract(filename)
    test_data = test_file.get_data()
    assert len(test_data) > 0
    assert len(test_data) == 10
    assert '2.9925' in test_data[1]
    remove_file(filename)
Пример #2
0
def test_get_coordinates():
    filename = str(uuid.uuid4())+".txt"
    create_file(filename)
    test_file = extract_class.Extract(filename)
    test_coordinates = test_file.get_coordinates()
    assert len(test_coordinates) > 0
    assert len(test_coordinates) == 10
    assert 222 not in test_coordinates[1]
    assert -48.57 == test_coordinates[0][0]
    remove_file(filename)
Пример #3
0
def test_evaluate():
    filename = str(uuid.uuid4()) + ".txt"
    create_file(filename)
    fuel_tank = fuel_tank_class.Fuel_tank()
    fuel_data = extract_class.Extract(filename)
    output_t = fuel_elimination_class.Fuel_elimination(fuel_tank, fuel_data)
    test_evaluation = output_t.evaluate()
    assert len(test_evaluation) > 0
    assert len(test_evaluation) == 10
    assert test_evaluation[1]['coord_r'] == 2.9925
    assert test_evaluation[0]['result'] == 'IN'
    assert test_evaluation[4]['coord_x'] == 52.4217
    assert test_evaluation[9]['coord_y'] == -39.3507
    assert '222' in test_evaluation[5]['raw_data']
    remove_file(filename)
Пример #4
0
def test_separate():
    filename = str(uuid.uuid4()) + ".txt"
    create_file(filename)
    fuel_tank = fuel_tank_class.Fuel_tank()
    fuel_data = extract_class.Extract(filename)
    output_t = fuel_elimination_class.Fuel_elimination(fuel_tank, fuel_data)
    output_t.separate('output_file_t.txt', 'IN')
    with open('output_file_t.txt', 'r') as file_t:
        data_t = file_t.readlines()
        file_t.close()
    assert len(data_t) == 3
    assert '-2.24541E+01' in data_t[2]
    assert '5.24217E+01' not in data_t
    assert len(data_t[1]) == 56
    remove_file(filename)
    remove_file('output_file_t.txt')
Пример #5
0
while True:
    #user chooses the path to the source file
    coordinates = input('Enter the filename:')
    if os.path.exists(coordinates):
        break
    else:
        print('File does not exist, try again.')

output_file_name = input('Select the output filename:')
#in case user will not type any particular output file name, unique name will be automatically generated
if len(output_file_name) == 0:
    output_file_name = str(uuid.uuid4())

fuel_tank = fuel_tank_class.Fuel_tank()
input_data = extract_class.Extract(coordinates)
output = fuel_elimination_class.Fuel_elimination(fuel_tank, input_data)

while True:
    #user chooses which cells he wants to generate file for, in case he does not make a selection, program will generate files for both, IN and OUT cells
    output_type = input('Select which cell coordinates you require to generate into file- IN/OUT/BOTH (Default will generate both files):')
    if output_type == 'IN':
        output.separate(output_file_name+'.inp', output_type)
        break
    elif output_type == 'OUT':
        output.separate(output_file_name+'.inp', output_type)
        break
    elif len(output_type) == 0:
        output.separate(output_file_name+'_in.inp', 'IN')
        output.separate(output_file_name+'_out.inp', 'OUT')
        break