Skip to content

Commit

Permalink
Typo (#224)
Browse files Browse the repository at this point in the history
* 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
4 people authored Jun 22, 2023
1 parent e71eea2 commit 304c478
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 62 deletions.
13 changes: 7 additions & 6 deletions modules/public_transport_procedures/gtfs_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ def __init__(self, qgis_project, pt_object, testing=False):
self.but_add.setVisible(False)
self.service_calendar.setVisible(False)
self.setFixedHeight(1)
if testing:
self.close()
else:
self.testing = testing
self.date = None
if not testing:
self.open_feed()
if self.feed is None:
self.close()

def open_feed(self):
from qaequilibrae.modules.common_tools.get_output_file_name import GetOutputFileName
Expand Down Expand Up @@ -78,7 +76,10 @@ def return_feed(self):
self.iface.messageBar().pushMessage("Error", "Enter agency and description", level=3, duration=10)
return

date = self.service_calendar.selectedDate().toString("yyyy-MM-dd")
if not self.testing:
date = self.service_calendar.selectedDate().toString("yyyy-MM-dd")
else:
date = self.date
self.feed.set_date(date)

caps = {}
Expand Down
4 changes: 2 additions & 2 deletions modules/public_transport_procedures/gtfs_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def __init__(self, qgis_project):
self.rdo_clear.setText("Overwrite Routes")
self.rdo_keep.setText("Add to Existing Routes")
else:
self.label_3.setText("Add Transit Table")
self.rdo_clear.setText("Crete New Route System")
self.label_3.setText("Add transit table")
self.rdo_clear.setText("Create new route system")
self.rdo_keep.setVisible(False)
self.rdo_clear.setChecked(True)
self.setFixedHeight(380)
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
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
10 changes: 10 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@ def pt_project(qgis_iface) -> AequilibraEMenu:
_run_load_project_from_path(ae, "test/data/coquimbo_project")
yield ae
ae.run_close_project()


@pytest.fixture(scope="function")
def pt_no_feed(qgis_iface) -> AequilibraEMenu:
ae = AequilibraEMenu(qgis_iface)
from qaequilibrae.modules.menu_actions.load_project_action import _run_load_project_from_path

_run_load_project_from_path(ae, "test/data/no_pt_feed")
yield ae
ae.run_close_project()
Binary file modified test/data/coquimbo_project/public_transport.sqlite
Binary file not shown.
Binary file added test/data/no_pt_feed/project_database.sqlite
Binary file not shown.
128 changes: 76 additions & 52 deletions test/test_pt_procedures.py
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

0 comments on commit 304c478

Please sign in to comment.