def test_get_project():
    rvr_prj_mgr = RiverProjectManager(rti_config)

    project = rvr_prj_mgr.get_project("Project2")

    # Project Name in file matches file
    assert os.path.join(os.getcwd(), "Project2.hdf5") == project.file_path
def test_get_project_list():
    rvr_prj_mgr = RiverProjectManager(rti_config)

    project = rvr_prj_mgr.create_project("Project2")
    with h5py.File(project.file_path, "a") as project_file:

        prjs_list = rvr_prj_mgr.get_project_list()
        assert len(prjs_list) >= 1

        assert True == ("Project2" in prjs_list)

        assert "Project2" == project_file.attrs[RiverProjectMeta.PROJECT_NAME]
def test_add_project_file_not_exist():
    rvr_prj_mgr = RiverProjectManager(rti_config)

    # File path should not exist so project file will be none
    project_file = rvr_prj_mgr.add_project(
        "Project23", os.path.join("./", "Project77.hdf5"))

    project_list = rvr_prj_mgr.get_project_list()

    assert False == ("Project23" in project_list)
    if project_file is None:
        assert True
    else:
        assert False
def test_add_project():
    rvr_prj_mgr = RiverProjectManager(rti_config)

    project = rvr_prj_mgr.add_project(
        "Project22",
        os.path.join(rti_config.config['RIVER']['output_dir'],
                     "Project1.hdf5"))
    project_list = rvr_prj_mgr.get_project_list()

    with h5py.File(project.file_path, "a") as project_file:

        # Project name in list matches list entry
        assert True == ("Project22" in project_list)
        # Project Name in file matches file
        assert "Project1" == project_file.attrs[RiverProjectMeta.PROJECT_NAME]
def test_create_project_exist():
    rvr_prj_mgr = RiverProjectManager(rti_config)
    project = rvr_prj_mgr.create_project("Project3")
    project1 = rvr_prj_mgr.create_project("Project3")  # Duplicate
    with h5py.File(project.file_path, "a") as project_file:
        with h5py.File(project1.file_path, "a") as project_file1:

            prjs_list = rvr_prj_mgr.get_project_list()
            assert len(prjs_list) >= 2

            assert True == ("Project3_0" in prjs_list)

            assert "Project3" == project_file.attrs[
                RiverProjectMeta.PROJECT_NAME]
            assert "Project3_0" == project_file1.attrs[
                RiverProjectMeta.PROJECT_NAME]
def test_create_project():
    rvr_prj_mgr = RiverProjectManager(rti_config)
    project = rvr_prj_mgr.create_project("Project1")
    with h5py.File(project.file_path, "a") as project_file:

        if project_file is not None:
            assert True
        else:
            assert False

        if RiverProjectMeta.PROJECT_NAME in project_file.attrs:
            assert True
        else:
            assert False

        assert "Project1" == project_file.attrs[RiverProjectMeta.PROJECT_NAME]
Example #7
0
    def __init__(self, socketio):
        self.plot = self.create_plot()
        self.socketio = socketio

        # RTI Configuration
        self.rti_config = RtiConfig(file_path="config.ini")
        self.rti_config.init_river_project_config()

        # Plot manager to keep track of plots
        self.plot_mgr = PlotManager(app_mgr=self, socketio=socketio)

        # River Project Manager to keep track of River projects
        self.river_prj_mrg = RiverProjectManager(self.rti_config)

        # ADCP Codec to decode the ADCP data
        self.adcp_codec = AdcpCodec()
        self.adcp_codec.ensemble_event += self.process_ensemble

        # Serial Port
        self.serial_port = None
        self.serial_thread = None
        self.serial_thread_alive = False

        self.app_state = {
            "is_serial_connected": False,  # Is the serial port connected
            "serial_status": [],  # Status of the serial connection
            "selected_serial_port": "",  # Comm port selected
            "selected_baud": "115200",  # Baud rate selected
            "is_serial_error": False,  # Any serial errors.
            "serial_error_status": [],  # List of error messages
            "baud_list":
            self.get_baud_rates(),  # List of all available Baud rates
            "serial_port_list":
            self.get_serial_ports(),  # List of all available Serial Ports
            "serial_raw_ascii": "",  # Raw ascii from the serial port
            "max_ascii_buff":
            10000,  # Maximum number of characters to keep in serial ASCII buffer
            "adcp_break": {},  # Results of a BREAK statement
            "adcp_ens_num": 0,  # Latest Ensemble number
            "selected_files": [],  # Selected files to playback,
            "selected_project_db": None,  # Selected Project,
            "prj_name": "",  # Current project name
            "prj_path": "",  # Current project folder path
        }

        self.transect_state = {
            "transect_index": 1,  # Current index for the transect
            "transect_dt_start": None,  # Start datetime of the transect
            "transect_duration": None,  # Time duration of the transect
            "voltage": 0.0,  # System Voltage
        }

        # Current Transect
        self.db_file = None  # DB file to store the ensembles and transects
        self.raw_file = None  # Raw binary file to the store the ensemble data
        self.is_record_raw_data = self.rti_config.config['RIVER'][
            'auto_save_raw']  # Automatically save on startup
        self.curr_ens_index = 0  # Index the project DB for the latest ensemble
        self.transect_index = 0  # Transect Index
        self.transect = None  # Current transect

        #self.is_volt_plot_init = False
        #self.voltage_queue = deque(maxlen=100)
        #self.ens_dt_queue = deque(maxlen=100)

        # Incoming serial data
        self.serial_raw_bytes = None
def test_constructor():

    # FIRST TEST RUN SO RUN SETUP
    setup_test()

    rvr_prj_mgr = RiverProjectManager(rti_config)
def test_add_transect():
    rvr_prj_mgr = RiverProjectManager(rti_config)