
import pytest

import datetime as dt

import pandas as pd
from pandas.api.types import is_datetime64_dtype

from dtocean_core.utils.maintenance import (update_comp_table,
                                            update_onsite_tables,
                                            update_replacement_tables,
                                            update_inspections_tables,
                                            get_events_table,
                                            get_electrical_system_cost,
                                            get_mandf_system_cost,
                                            _get_elec_db_cost)


@pytest.fixture(scope="module")
def corrective_events_table():
    
    events_dict = \
        {'ComponentID [-]': {0: 'Array elec sub-system003',
                             1: 'Export Cable001',
                             2: 'Array elec sub-system004',
                             3: 'Array elec sub-system002',
                             4: 'Array elec sub-system004',
                             5: 'Pto003',
                             6: 'Array elec sub-system001',
                             7: 'Array elec sub-system002',
                             8: 'Array elec sub-system004',
                             9: 'Array elec sub-system003',
                             10: 'Array elec sub-system001',
                             11: 'Pto003',
                             12: 'Array elec sub-system004',
                             13: 'Array elec sub-system001',
                             14: 'Array elec sub-system003',
                             15: 'Pto001',
                             16: 'Pto004',
                             17: 'Hydrodynamic001',
                             18: 'Array elec sub-system004',
                             19: 'Array elec sub-system003',
                             20: 'Array elec sub-system002',
                             21: 'Array elec sub-system003',
                             22: 'Array elec sub-system004',
                             23: 'Array elec sub-system001',
                             24: 'Array elec sub-system001',
                             25: 'Array elec sub-system002',
                             26: 'Array elec sub-system001',
                             27: 'Array elec sub-system004',
                             28: 'Array elec sub-system002',
                             29: 'Array elec sub-system002',
                             30: 'Array elec sub-system001'},
         'ComponentSubType [-]': {0: 'Array elec sub-system',
                                  1: 'Export Cable',
                                  2: 'Array elec sub-system',
                                  3: 'Array elec sub-system',
                                  4: 'Array elec sub-system',
                                  5: 'Pto',
                                  6: 'Array elec sub-system',
                                  7: 'Array elec sub-system',
                                  8: 'Array elec sub-system',
                                  9: 'Array elec sub-system',
                                  10: 'Array elec sub-system',
                                  11: 'Pto',
                                  12: 'Array elec sub-system',
                                  13: 'Array elec sub-system',
                                  14: 'Array elec sub-system',
                                  15: 'Pto',
                                  16: 'Pto',
                                  17: 'Hydrodynamic',
                                  18: 'Array elec sub-system',
                                  19: 'Array elec sub-system',
                                  20: 'Array elec sub-system',
                                  21: 'Array elec sub-system',
                                  22: 'Array elec sub-system',
                                  23: 'Array elec sub-system',
                                  24: 'Array elec sub-system',
                                  25: 'Array elec sub-system',
                                  26: 'Array elec sub-system',
                                  27: 'Array elec sub-system',
                                  28: 'Array elec sub-system',
                                  29: 'Array elec sub-system',
                                  30: 'Array elec sub-system'},
         'ComponentType [-]': {0: 'device003',
                               1: 'Export Cable001',
                               2: 'device004',
                               3: 'device002',
                               4: 'device004',
                               5: 'device003',
                               6: 'device001',
                               7: 'device002',
                               8: 'device004',
                               9: 'device003',
                               10: 'device001',
                               11: 'device003',
                               12: 'device004',
                               13: 'device001',
                               14: 'device003',
                               15: 'device001',
                               16: 'device004',
                               17: 'device001',
                               18: 'device004',
                               19: 'device003',
                               20: 'device002',
                               21: 'device003',
                               22: 'device004',
                               23: 'device001',
                               24: 'device001',
                               25: 'device002',
                               26: 'device001',
                               27: 'device004',
    
                           28: 'device002',
                               29: 'device002',
      
                         30: 'device001'},
         'FM_ID [-]': {0: 'MoS7',
                       1: 'MoS7',
                       2: 'MoS7',
                       3: 'MoS7',
                       4: 'MoS7',
                       5: 'RtP2',
                       6: 'MoS7',
                       7: 'MoS7',
                       8: 'MoS7',
                       9: 'MoS7',
                       10: 'MoS7',
                       11: 'MoS4',
                       12: 'MoS7',
                       13: 'MoS7',
                       14: 'MoS7',
                       15: 'RtP2',
                       16: 'RtP2',
                       17: 'RtP2',
                       18: 'MoS7',
                       19: 'MoS7',
                       20: 'MoS7',
                       21: 'MoS7',
                       22: 'MoS7',
                       23: 'MoS7',
                       24: 'MoS7',
                       25: 'MoS7',
                       26: 'MoS7',
                       27: 'MoS7',
                       28: 'MoS7',
                       29: 'MoS7',
                       30: 'MoS7'},
         'RA_ID [-]': {0: 'LpM5',
                       1: 'LpM5',
                       2: 'LpM5',
                       3: 'LpM5',
                       4: 'LpM5',
                       5: 'LpM6',
                       6: 'LpM5',
                       7: 'LpM5',
                       8: 'LpM5',
                       9: 'LpM5',
                       10: 'LpM5',
                       11: 'LpM3',
                       12: 'LpM5',
                       13: 'LpM5',
                       14: 'LpM5',
                       15: 'LpM6',
                       16: 'LpM6',
                       17: 'LpM6',
                       18: 'LpM5',
                       19: 'LpM5',
                       20: 'LpM5',
                       21: 'LpM5',
                       22: 'LpM5',
                       23: 'LpM5',
                       24: 'LpM5',
                       25: 'LpM5',
                       26: 'LpM5',
                       27: 'LpM5',
                       28: 'LpM5',
                       29: 'LpM5',
                       30: 'LpM5'},
         'costLogistic [Euro]': {0: 472056,
                                 1: 472081L,
                                 2: 472011L,
                             