# Path: urbanaccess/network.py
# class urbanaccess_network(object):
#     """
#     An urbanaccess object of pandas.DataFrames representing
#     the components of a graph network
# 
#     Parameters
#     ----------
#     transit_nodes : pandas.DataFrame
#     transit_edges : pandas.DataFrame
#     net_connector_edges : pandas.DataFrame
#     osm_nodes : pandas.DataFrame
#     osm_edges : pandas.DataFrame
#     net_nodes : pandas.DataFrame
#     net_edges : pandas.DataFrame
#     """
# 
#     def __init__(self,
#                  transit_nodes=pd.DataFrame(),
#                  transit_edges=pd.DataFrame(),
#                  net_connector_edges=pd.DataFrame(),
#                  osm_nodes=pd.DataFrame(),
#                  osm_edges=pd.DataFrame(),
#                  net_nodes=pd.DataFrame(),
#                  net_edges=pd.DataFrame()):
#         self.transit_nodes = transit_nodes
#         self.transit_edges = transit_edges
#         self.net_connector_edges = net_connector_edges
#         self.osm_nodes = osm_nodes
#         self.osm_edges = osm_edges
#         self.net_nodes = net_nodes
#         self.net_edges = net_edges
# 
# Path: urbanaccess/gtfs/gtfsfeeds_dataframe.py
# class urbanaccess_gtfs_df(object):
#     """
#     A collection of DataFrames representing the standardized and
#     merged metropolitan-wide transit network from multiple
#     GTFS feeds.
# 
#     Parameters
#     ----------
#     gtfsfeeds_dfs : object
#         processed DataFrames of corresponding GTFS feed text files
#     gtfsfeeds_dfs.stops : pandas.DataFrame
#     gtfsfeeds_dfs.routes : pandas.DataFrame
#     gtfsfeeds_dfs.trips : pandas.DataFrame
#     gtfsfeeds_dfs.stop_times : pandas.DataFrame
#     gtfsfeeds_dfs.calendar : pandas.DataFrame
#     gtfsfeeds_dfs.calendar_dates : pandas.DataFrame
#     gtfsfeeds_dfs.stop_times_int : pandas.DataFrame
#     gtfsfeeds_dfs.headways : pandas.DataFrame
#     """
# 
#     def __init__(self,
#                  stops=pd.DataFrame(),
#                  routes=pd.DataFrame(),
#                  trips=pd.DataFrame(),
#                  stop_times=pd.DataFrame(),
#                  calendar=pd.DataFrame(),
#                  calendar_dates=pd.DataFrame(),
#                  stop_times_int=pd.DataFrame(),
#                  headways=pd.DataFrame()):
#         self.stops = stops
#         self.routes = routes
#         self.trips = trips
#         self.stop_times = stop_times
#         self.calendar = calendar
#         self.calendar_dates = calendar_dates
#         self.stop_times_int = stop_times_int
#         self.headways = headways


import pytest
import os
import time
import glob
import pandas as pd
import numpy as np
import urbanaccess.gtfs.network as gtfs_network
import urbanaccess.gtfs.load as gtfs_load
from urbanaccess.network import urbanaccess_network
from urbanaccess.gtfs.gtfsfeeds_dataframe import urbanaccess_gtfs_df
                      'DataFrame: stop_times_int.')
    assert expected_error in str(excinfo.value)

    # set stop_times_int df for test
    gtfs_feed_wo_calendar_dates.stop_times_int = \
        selected_int_stop_times_from_feed_wo_calendar_dates
    # set calendar df to blank df for test
    gtfs_feed_wo_calendar_dates.calendar = pd.DataFrame()
    with pytest.raises(ValueError) as excinfo:
        gtfs_network.save_processed_gtfs_data(
            gtfs_feed_wo_calendar_dates,
            filename='test_file.h5', dir=dir_path)
    expected_error = ('gtfsfeeds_dfs is missing either the calendar or '
                      'calendar_dates DataFrame.')
    assert expected_error in str(excinfo.value)

    # test with incorrect dtype as param
    with pytest.raises(ValueError) as excinfo:
        gtfs_network.save_processed_gtfs_data(
            'invalid_param',
            filename='test_file.h5', dir=dir_path)
    expected_error = ('gtfsfeeds_dfs must be an urbanaccess_gtfs_df '
                      'object.')
    assert expected_error in str(excinfo.value)


def test_load_processed_gtfs_data(
        hdf5_file_on_disk_gtfsfeeds_dfs, expected_gtfsfeeds_dfs_keys):
    gtfsfeeds_dfs = gtfs_network.load_processed_gtfs_data(
        filename='test_file.h5', dir=hdf5_file_on_disk_gtfsfeeds_dfs)

# Path: urbanaccess/network.py
# class urbanaccess_network(object):
#     """
#     An urbanaccess object of pandas.DataFrames representing
#     the components of a graph network
# 
#     Parameters
#     ----------
#     transit_nodes : pandas.DataFrame
#     transit_edges : pandas.DataFrame
#     net_connector_edges : pandas.DataFrame
#     osm_nodes : pandas.DataFrame
#     osm_edges : pandas.DataFrame
#     net_nodes : pandas.DataFrame
#     net_edges : pandas.DataFrame
#     """
# 
#     def __init__(self,
#                  transit_nodes=pd.DataFrame(),
#                  transit_edges=pd.DataFrame(),
#                  net_connector_edges=pd.DataFrame(),
#                  osm_nodes=pd.DataFrame(),
#                  osm_edges=pd.DataFrame(),
#                  net_nodes=pd.DataFrame(),
#                  net_edges=pd.DataFrame()):
#         self.transit_nodes = transit_nodes
#         self.transit_edges = transit_edges
#         self.net_connector_edges = net_connector_edges
#         self.osm_nodes = osm_nodes
#         self.osm_edges = osm_edges
#         self.net_nodes = net_nodes
#         self.net_edges = net_edges
# 
# Path: urbanaccess/gtfs/gtfsfeeds_dataframe.py
# class urbanaccess_gtfs_df(object):
#     """
#     A collection of DataFrames representing the standardized and
#     merged metropolitan-wide transit network from multiple
#     GTFS feeds.
# 
#     Parameters
#     ----------
#     gtfsfeeds_dfs : object
#         processed DataFrames of corresponding GTFS feed text files
#     gtfsfeeds_dfs.stops : pandas.DataFrame
#     gtfsfeeds_dfs.routes : pandas.DataFrame
#     gtfsfeeds_dfs.trips : pandas.DataFrame
#     gtfsfeeds_dfs.stop_times : pandas.DataFrame
#     gtfsfeeds_dfs.calendar : pandas.DataFrame
#     gtfsfeeds_dfs.calendar_dates : pandas.DataFrame
#     gtfsfeeds_dfs.stop_times_int : pandas.DataFrame
#     gtfsfeeds_dfs.headways : pandas.DataFrame
#     """
# 
#     def __init__(self,
#                  stops=pd.DataFrame(),
#                  routes=pd.DataFrame(),
#                  trips=pd.DataFrame(),
#                  stop_times=pd.DataFrame(),
#                  calendar=pd.DataFrame(),
#                  calendar_dates=pd.DataFrame(),
#                  stop_times_int=pd.DataFrame(),
#                  headways=pd.DataFrame()):
#         self.stops = stops
#         self.routes = routes
#         self.trips = trips
#         self.stop_times = stop_times
#         self.calendar = calendar
#         self.calendar_dates = calendar_dates
#         self.stop_times_int = stop_times_int
#         self.headways = headways


# Path: urbanaccess/tests/test_gtfs_network.py
import pytest
import os
import time
import glob
import pandas as pd
import numpy as np
import urbanaccess.gtfs.network as gtfs_network
import urbanaccess.gtfs.load as gtfs_load
from urbanaccess.network import urbanaccess_network
from urbanaccess.gtfs.gtfsfeeds_dataframe import urbanaccess_gtfs_df

                      'DataFrame: stop_times_int.')
    assert expected_error in str(excinfo.value)

    # set stop_times_int df for test
    gtfs_feed_wo_calendar_dates.stop_times_int = \
        selected_int_stop_times_from_feed_wo_calendar_dates
    # set calendar df to blank df for test
    gtfs_feed_wo_calendar_dates.calendar = pd.DataFrame()
    with pytest.raises(ValueError) as excinfo:
        gtfs_network.save_processed_gtfs_data(
            gtfs_feed_wo_calendar_dates,
            filename='test_file.h5', dir=dir_path)
    expected_error = ('gtfsfeeds_dfs is missing either the calendar or '
                      'calendar_dates DataFrame.')
    assert expected_error in str(excinfo.value)

    # test with incorrect dtype as param
    with pytest.raises(ValueError) as excinfo:
        gtfs_network.save_processed_gtfs_data(
            'invalid_param',
            filename='test_file.h5', dir=dir_path)
    expected_error = ('gtfsfeeds_dfs must be an urbanaccess_gtfs_df '
                      'object.')
    assert expected_error in str(excinfo.value)


def test_load_processed_gtfs_data(
        hdf5_file_on_disk_gtfsfeeds_dfs, expected_gtfsfeeds_dfs_keys):
    gtfsfeeds_dfs = gtfs_network.load_processed_gtfs_data(
        filename='test_file.h5', dir=hdf5_file_on_disk_gtfsfeeds_dfs)

    assert isinstance(gtfsfeeds_dfs, urbanaccess_gtfs_df)