-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Typo * removes excessive capitalization * Changes PT Procedures test * Changes assertion in test * Changes assertion in test * Changes assertion in test * Changes assertion in test[B * Check if feed is not None * Check if feed info is added * Updates PT procedure test * Updates PT procedure test * Updates PT procedure test * Updates PT procedure test * Changes PT Procedures Test * Removes test skip * Changes PT Procedures test * Changes PT Procedures test * Changes in GTFS Feed * Modifies test * Changes PT Proceduresd test * Adds file and changes test * Temporarily changes requirements * Modifies PT Procedure Tests --------- Co-authored-by: pveigadecamargo <[email protected]> Co-authored-by: Renata Imai <[email protected]> Co-authored-by: Renata Imai <[email protected]>
- Loading branch information
1 parent
e71eea2
commit 304c478
Showing
7 changed files
with
96 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
aequilibrae==0.9.2.dev0;python_version<="3.9" | ||
aequilibrae==0.9.2;python_version>"3.9" | ||
aequilibrae @ git+https://github.com/AequilibraE/aequilibrae@develop | ||
openmatrix | ||
ortools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,97 @@ | ||
import os | ||
import sqlite3 | ||
import pytest | ||
from PyQt5.QtCore import Qt, QTimer | ||
from PyQt5.QtWidgets import QApplication | ||
from qgis.core import QgsProject, Qgis, QgsVectorLayer | ||
from PyQt5.QtCore import QTimer | ||
from qaequilibrae.modules.public_transport_procedures.gtfs_feed import GTFSFeed | ||
from qaequilibrae.modules.public_transport_procedures.gtfs_importer import GTFSImporter | ||
|
||
|
||
def test_click_new_importer(ae_with_project, qtbot): | ||
dialog = GTFSImporter(ae_with_project) | ||
dialog.show() | ||
|
||
assert dialog.label_3.text() == "Add Transit Table" | ||
assert dialog.rdo_clear.text() == "Crete New Route System" | ||
|
||
with qtbot.capture_exceptions() as exceptions: | ||
qtbot.mouseClick(dialog.but_execute, Qt.LeftButton) | ||
def test_pt_menu(ae_with_project, qtbot): | ||
from qaequilibrae.modules.public_transport_procedures.gtfs_importer import GTFSImporter | ||
from test.test_qaequilibrae_menu_with_project import check_if_new_active_window_matches_class | ||
|
||
assert len(exceptions) == 0, "Exception shouldn't be raised all the way to here" | ||
|
||
dialog.close() | ||
def handle_trigger(): | ||
check_if_new_active_window_matches_class(qtbot, GTFSImporter) | ||
|
||
action = ae_with_project.menuActions["Public Transport"][0] | ||
assert action.text() == "Import GTFS", "Wrong text content" | ||
QTimer.singleShot(10, handle_trigger) | ||
action.trigger() | ||
messagebar = ae_with_project.iface.messageBar() | ||
assert len(messagebar.messages[3]) == 0, "Messagebar should be empty" + str(messagebar.messages) | ||
|
||
def test_click_add_importer(pt_project, qtbot): | ||
dialog = GTFSImporter(pt_project) | ||
dialog.show() | ||
|
||
assert dialog.rdo_clear.text() == "Overwrite Routes" | ||
assert dialog.rdo_keep.text() == "Add to Existing Routes" | ||
def test_add_new_feed(pt_no_feed): | ||
from aequilibrae.transit import Transit | ||
|
||
with qtbot.capture_exceptions() as exceptions: | ||
qtbot.mouseClick(dialog.but_execute, Qt.LeftButton) | ||
importer = GTFSImporter(pt_no_feed) | ||
assert importer.label_3.text() == "Add transit table" | ||
assert importer.rdo_clear.text() == "Create new route system" | ||
|
||
assert len(exceptions) == 0, "Exception shouldn't be raised all the way to here" | ||
data = Transit(pt_no_feed.project) | ||
feed = GTFSFeed(pt_no_feed, data, True) | ||
|
||
dialog.close() | ||
assert feed.label.text() == "Route capacities" | ||
assert feed.label_2.text() == "Service date" | ||
assert feed.label_3.text() == "Description*" | ||
assert feed.label_4.text() == "Agency*" | ||
|
||
gtfs_file = "test/data/coquimbo_project/gtfs_coquimbo.zip" | ||
feed.set_data(gtfs_file) | ||
feed.led_agency.setText("New agency") | ||
feed.led_description.setText("Adds new agency description") | ||
feed.date = "2016-04-13" | ||
feed.return_feed() | ||
|
||
def test_click_feed(pt_project, qtbot): | ||
from aequilibrae.transit import Transit | ||
|
||
data = Transit(pt_project.project) | ||
importer.set_feed(feed.feed) | ||
importer.rdo_keep.setChecked(True) | ||
importer.execute_importer() | ||
|
||
dialog = GTFSFeed(pt_project, data, True) | ||
dialog.show() | ||
qtbot.addWidget(dialog) | ||
qtbot.waitExposed(dialog) | ||
db_path = os.path.join(pt_no_feed.project.project_base_path, "public_transport.sqlite") | ||
conn = sqlite3.connect(db_path) | ||
var = conn.execute("select count(agency_id) from agencies").fetchone()[0] | ||
|
||
assert dialog.label.text() == "Route capacities" | ||
assert dialog.label_2.text() == "Service date" | ||
assert dialog.label_3.text() == "Description*" | ||
assert dialog.label_4.text() == "Agency*" | ||
assert var == 1 | ||
|
||
with qtbot.capture_exceptions() as exceptions: | ||
qtbot.mouseClick(dialog.but_new_row, Qt.LeftButton) | ||
|
||
assert len(exceptions) == 0, "Exception shouldn't be raised all the way to here" | ||
|
||
|
||
def test_pt_menu(ae_with_project, qtbot): | ||
from qaequilibrae.modules.public_transport_procedures.gtfs_importer import GTFSImporter | ||
from test.test_qaequilibrae_menu_with_project import check_if_new_active_window_matches_class | ||
@pytest.mark.parametrize( | ||
("is_checked", "set_date", "set_agency"), | ||
[(False, "2016-06-17", "New agency"), (True, "2016-08-21", "Other agency")], | ||
) | ||
def test_add_other_feed(pt_project, set_agency, set_date, is_checked): | ||
from aequilibrae.transit import Transit | ||
|
||
def handle_trigger(): | ||
check_if_new_active_window_matches_class(qtbot, GTFSImporter) | ||
importer = GTFSImporter(pt_project) | ||
assert importer.label_3.text() == "Resetting Transit Tables" | ||
assert importer.rdo_clear.text() == "Overwrite Routes" | ||
assert importer.rdo_keep.text() == "Add to Existing Routes" | ||
|
||
action = ae_with_project.menuActions["Public Transport"][0] | ||
assert action.text() == "Import GTFS", "Wrong text content" | ||
QTimer.singleShot(10, handle_trigger) | ||
action.trigger() | ||
messagebar = ae_with_project.iface.messageBar() | ||
assert len(messagebar.messages[3]) == 0, "Messagebar should be empty" + str(messagebar.messages) | ||
data = Transit(pt_project.project) | ||
feed = GTFSFeed(pt_project, data, True) | ||
|
||
assert feed.label.text() == "Route capacities" | ||
assert feed.label_2.text() == "Service date" | ||
assert feed.label_3.text() == "Description*" | ||
assert feed.label_4.text() == "Agency*" | ||
|
||
gtfs_file = "test/data/coquimbo_project/gtfs_coquimbo.zip" | ||
feed.set_data(gtfs_file) | ||
feed.led_agency.setText(set_agency) | ||
feed.led_description.setText("Adds new agency description") | ||
feed.date = set_date | ||
feed.return_feed() | ||
|
||
importer.rdo_clear.setChecked(is_checked) | ||
if not is_checked: | ||
importer.rdo_keep.setChecked(True) | ||
importer.set_feed(feed.feed) | ||
importer.execute_importer() | ||
|
||
db_path = os.path.join(pt_project.project.project_base_path, "public_transport.sqlite") | ||
conn = sqlite3.connect(db_path) | ||
var = conn.execute("select count(agency_id) from agencies").fetchone()[0] | ||
|
||
if is_checked: | ||
assert var == 1 | ||
else: | ||
assert var == 2 |