Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,46 @@ jobs:
python -m pip check
python -m pytest -m "not network"

notebook-and-integration:
name: Demo notebook and integration scripts
runs-on: ubuntu-latest
timeout-minutes: 20
env:
MPLBACKEND: Agg
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install package and notebook dependencies
run: |
python -m pip install --upgrade pip
python -m pip install . jupyter cartopy pyepsg
- name: Convert demo notebook to script
run: |
cd demo
jupyter nbconvert --to python simple_example.ipynb
- name: Strip notebook magics
run: |
cd urbanaccess/tests/integration
python remove_nb_magic.py -in simple_example.py -out simple_example_clean.py
# Allowed to fail: Expected failure given GTFSDataExchange is no longer active notebook needs a re-write to remove those references and an update and release of OSMnet is required
- name: Run demo notebook script (requires removal of GTFSDataExchange and an OSMnet update and release)
continue-on-error: true
run: |
cd demo
python simple_example_clean.py
# Allowed to fail: Expected failure update and release of OSMnet is required and .str accessor error on agency.txt dtype config is already solved in a more recent branch
- name: Run Madison integration test (requires OSMnet update and release and use of latest branch to solve .str accessor error)
continue-on-error: true
run: |
cd urbanaccess/tests/integration
python integration_madison.py
- name: Run San Diego integration test
run: |
cd urbanaccess/tests/integration
python integration_sandiego.py

package:
name: Package build and install
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion urbanaccess/tests/integration/integration_madison.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
start_time = time.time()

name = 'madison'
url = 'http://www.gtfs-data-exchange.com/agency/city-of-madison/latest.zip'
url = 'http://transitdata.cityofmadison.com/GTFS/mmt_gtfs.zip'

print('-------------------------')
print('Starting integration test for {}...'.format(name))
Expand Down
9 changes: 5 additions & 4 deletions urbanaccess/tests/integration/integration_sandiego.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@
import cartopy.crs as ccrs

import urbanaccess
from urbanaccess.gtfsfeeds import feeds

start_time = time.time()

name = 'san diego'
url = 'https://www.sdmts.com/google_transit_files/google_transit.zip'

print('-------------------------')
print('Starting integration test for {}...'.format(name))

new_feed = {name: url}
feeds.add_feed(new_feed)

script_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.join(script_path, 'data', name)
data_path = os.path.join(root_path, 'gtfsfeed_text')

urbanaccess.gtfsfeeds.search(search_text=name, add_feed=True)

urbanaccess.gtfsfeeds.download(data_folder=root_path)

validation = True
Expand All @@ -42,8 +45,6 @@
transit_net = urbanaccess.gtfs.network.create_transit_net(
gtfsfeeds_dfs=loaded_feeds,
day='monday',
calendar_dates_lookup={'exception_note': ['FINAL', 'WD'],
'schedule_type': 'WD'},
timerange=['07:00:00', '10:00:00'])

# This is the standard map projection for California
Expand Down
40 changes: 19 additions & 21 deletions urbanaccess/tests/test_gtfsfeeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,26 @@ def feed_dict1():
def feed_dict2():
return {
'Bay Area Rapid Transit':
'http://www.gtfs-data-exchange.com/agency/bay-area-rapid-transit'
'/latest.zip'}
'https://www.bart.gov/dev/schedules/google_transit.zip'}


@pytest.fixture
def feed_dict3():
return {
'ac transit': 'http://www.actransit.org/wp-content/uploads'
'/GTFSJune182017B.zip',
'ac transit':
'http://www.actransit.org/wp-content/uploads/GTFSJune182017B.zip',
'Bay Area Rapid Transit':
'http://www.gtfs-data-exchange.com/agency/bay-area-rapid-transit'
'/latest.zip'}
'https://www.bart.gov/dev/schedules/google_transit.zip'}


@pytest.fixture
def feed_yaml(tmpdir):
yaml_dict = {
'gtfs_feeds': {
'ac transit': 'http://www.actransit.org/wp-content/uploads'
'/GTFSJune182017B.zip',
'ac transit':
'http://www.actransit.org/wp-content/uploads/GTFSJune182017B.zip',
'Bay Area Rapid Transit':
'http://www.gtfs-data-exchange.com/agency/bay-area-rapid'
'-transit/latest.zip'}}
'https://www.bart.gov/dev/schedules/google_transit.zip'}}

yaml_path = os.path.join(tmpdir.strpath, 'gtfsfeeds.yaml')
with open(yaml_path, 'w') as f:
Expand Down Expand Up @@ -100,8 +97,7 @@ def test_from_yaml_feed(feed_yaml):
assert isinstance(feeds_from_yaml, gtfsfeeds.urbanaccess_gtfsfeeds)
assert len(feeds_from_yaml.gtfs_feeds.keys()) == 2

valid_feed = ('http://www.gtfs-data-exchange.com/'
'agency/bay-area-rapid-transit/latest.zip')
valid_feed = ('https://www.bart.gov/dev/schedules/google_transit.zip')
assert feeds_from_yaml.gtfs_feeds['Bay Area Rapid Transit'] == valid_feed

valid_feed = ('http://www.actransit.org/wp-content/'
Expand All @@ -111,7 +107,9 @@ def test_from_yaml_feed(feed_yaml):
feeds.remove_feed(remove_all=True)


@pytest.mark.network
@pytest.mark.xfail(
reason="GTFSDataExchange no longer exists, needs depreciation and future "
"replacement")
def test_search_contains_gtfs_data_exchange():
search_result = gtfsfeeds.search(api='gtfsdataexch',
search_text=['ac transit', 'santa rosa'],
Expand All @@ -132,7 +130,9 @@ def test_search_contains_gtfs_data_exchange():
assert value in list(search_result['dataexchange_id'])


@pytest.mark.network
@pytest.mark.xfail(
reason="GTFSDataExchange no longer exists, needs depreciation and future "
"replacement")
def test_search_contains_add_feed_gtfs_data_exchange():
gtfsfeeds.search(api='gtfsdataexch',
search_text='ac transit',
Expand All @@ -154,7 +154,9 @@ def test_search_contains_add_feed_gtfs_data_exchange():
feeds.remove_feed(remove_all=True)


@pytest.mark.network
@pytest.mark.xfail(
reason="GTFSDataExchange no longer exists, needs depreciation and future "
"replacement")
def test_search_exact_search_field_gtfs_data_exchange():
# test search field
search_result = gtfsfeeds.search(api='gtfsdataexch',
Expand All @@ -164,7 +166,6 @@ def test_search_exact_search_field_gtfs_data_exchange():
assert len(search_result) == 8


@pytest.mark.network
def test_download_gtfs_feed_via_feed_object(feed_dict3, tmpdir):
feeds.add_feed(add_dict=feed_dict3)
tmp_path = tmpdir.strpath
Expand All @@ -188,22 +189,19 @@ def test_download_gtfs_feed_via_feed_object(feed_dict3, tmpdir):
feeds.remove_feed(remove_all=True)


@pytest.mark.network
def test_download_gtfs_feed_via_feed_name_and_dict(tmpdir):
tmp_path = tmpdir.strpath
gtfsfeeds.download(
data_folder=tmp_path,
feed_name='test_agency',
feed_url=('http://www.gtfs-data-exchange.com/'
'agency/bay-area-rapid-transit/latest.zip'),
feed_url=('https://www.bart.gov/dev/schedules/google_transit.zip'),
feed_dict=None,
error_pause_duration=5, delete_zips=False)

gtfsfeeds.download(
data_folder=tmp_path,
feed_dict={
'test_agency_dict': 'http://www.gtfs-data-exchange.com/agency/'
'ac-transit/latest.zip'},
'test_agency_dict': 'http://www.actransit.org/wp-content/uploads/GTFSJune182017B.zip'},
error_pause_duration=5, delete_zips=False)

filelist = ['test_agency.zip', 'test_agency_dict.zip']
Expand Down
2 changes: 1 addition & 1 deletion urbanaccess/tests/test_osm_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def bbox1():
return (-122.2762870789, 37.8211879615, -122.2701716423, 37.8241329692)


@pytest.mark.network
@pytest.mark.xfail(reason="requires OSMnet update and release")
def test_column_names(bbox1):
nodes, edges = ua_network_from_bbox(
bbox=bbox1, network_type='walk',
Expand Down
Loading