def test_encode_csv_vector_no_gen():
    num_bins = 30
    num_beams = 4

    vel = EarthVelocity(num_bins, num_beams)

    # Populate data
    val = 2.0
    for beam in range(vel.element_multiplier):
        for bin_num in range(vel.num_elements):
            vel.Velocities[bin_num][beam] = val
    vel.Magnitude, vel.Direction = EarthVelocity.generate_vectors(
        vel.Velocities)

    vel.remove_vessel_speed(-1.3, -1.4, 0.3)

    dt = datetime.datetime.now()

    # Create CSV lines
    result = vel.encode_csv(dt, 'A', 1, 1.3, 1.0)

    # Check the csv data
    for line in result:
        if bool(re.search(Ensemble.CSV_MAG, line[0])):
            assert bool(re.search(str(2.477), line[0]))
            assert bool(re.search(Ensemble.CSV_MAG, line[0]))
        elif bool(re.search(Ensemble.CSV_DIR, line[0])):
            assert bool(re.search(str(49.3987), line[0]))
            assert bool(re.search(Ensemble.CSV_DIR, line[0]))
        elif bool(re.search(Ensemble.CSV_EARTH_VEL, line[0])):
            assert True
        else:
            assert False
def test_encode_csv():
    num_bins = 30
    num_beams = 4

    vel = EarthVelocity(num_bins, num_beams)

    # Populate data
    val = 1.0
    for beam in range(vel.element_multiplier):
        for bin_num in range(vel.num_elements):
            vel.Velocities[bin_num][beam] = val
            val += 1.1
    vel.Magnitude, vel.Direction = EarthVelocity.generate_vectors(
        vel.Velocities)

    dt = datetime.datetime.now()

    # Create CSV lines
    result = vel.encode_csv(dt, 'A', 1, 1.3, 1.0)

    # Check the csv data
    test_value = 1.0
    for line in result:
        if bool(re.search(Ensemble.CSV_EARTH_VEL, line[0])):
            assert bool(re.search(str(test_value), line[0]))
            assert bool(re.search(Ensemble.CSV_EARTH_VEL, line[0]))
            test_value += 1.1