This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from OneBusAway/2to3
Python 2 -> 3, end to end tests, and CI
- Loading branch information
Showing
10 changed files
with
2,756 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: End-to-End Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
|
||
jobs: | ||
run-e2e-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Run End-to-End tests | ||
run: python test_e2e.py |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
__pycache__ | ||
./regions.xml | ||
./regions.json | ||
./regions-v3.xml | ||
./regions-v3.json | ||
tests/tmp/*.json | ||
tests/tmp/*.xml |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
|
||
import subprocess | ||
import unittest | ||
import os | ||
|
||
class TestEndToEnd(unittest.TestCase): | ||
@staticmethod | ||
def read_file_as_string(file_path): | ||
# Determine the directory of the current script (test_e2e.py) | ||
current_script_directory = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
# Construct an absolute path by combining the script directory with the relative file path | ||
absolute_file_path = os.path.join(current_script_directory, file_path) | ||
|
||
with open(absolute_file_path, 'r', encoding='utf-8') as file: | ||
return file.read() | ||
|
||
def test_update_regions_output(self): | ||
command = ["python", "update_regions.py", "--input-file", "./tests/fixtures/server_directory.csv", "--output-dir", "./tests/tmp", "--pretty"] | ||
_ = subprocess.run(command, capture_output=True, text=True) | ||
|
||
regions_xml_fixture = self.read_file_as_string('tests/fixtures/regions.xml') | ||
regions_xml_output = self.read_file_as_string('tests/tmp/regions.xml') | ||
self.assertEqual(regions_xml_fixture, regions_xml_output, "regions.xml should be identical") | ||
|
||
regions_xml_v3_fixture = self.read_file_as_string('tests/fixtures/regions-v3.xml') | ||
regions_xml_v3_output = self.read_file_as_string('tests/tmp/regions-v3.xml') | ||
self.assertEqual(regions_xml_v3_fixture, regions_xml_v3_output, "regions-v3.xml should be identical") | ||
|
||
regions_json_fixture = self.read_file_as_string('tests/fixtures/regions.json') | ||
regions_json_output = self.read_file_as_string('tests/tmp/regions.json') | ||
self.assertEqual(regions_json_fixture, regions_json_output, "regions.json should be identical") | ||
|
||
regions_json_v3_fixture = self.read_file_as_string('tests/fixtures/regions-v3.json') | ||
regions_json_v3_output = self.read_file_as_string('tests/tmp/regions-v3.json') | ||
self.assertEqual(regions_json_v3_fixture, regions_json_v3_output, "regions-v3.json should be identical") | ||
|
||
# This allows the test to be run from the command line | ||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.