-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d18145c
commit b8da233
Showing
6 changed files
with
140 additions
and
46 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,48 @@ | ||
name: Build | ||
|
||
on: push | ||
|
||
jobs: | ||
checks: | ||
name: Checks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install python deps | ||
run: pip install -r requirements.txt | ||
- name: Install optional build tools | ||
run: pip install pycodestyle pyflakes nose2 | ||
- name: Check flakes | ||
run: pyflakes *.py | ||
- name: Check style | ||
run: pycodestyle *.py | ||
- name: Check types | ||
run: mypy *.py | ||
- name: Run unit tests | ||
run: nose2 | ||
pipeline: | ||
name: Pipeline | ||
runs-on: ubuntu-latest | ||
needs: [checks] | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install python deps | ||
run: pip install -r requirements.txt | ||
- name: Run visualization | ||
run: python draw_berkeley_bart.py berkeley_trips.csv berkeley_trips.png | ||
- name: Upload result | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: berkeley_trips | ||
path: berkeley_trips.png |
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 @@ | ||
__pycache__ |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pycodestyle] | ||
max-line-length = 100 | ||
ignore = E125,E128,E502,E731,E722,E402 |
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,40 @@ | ||
"""Unit tests for the BART Berkeley trips visualization. | ||
License: BSD | ||
""" | ||
|
||
import unittest | ||
|
||
import sketchingpy | ||
|
||
import draw_berkeley_bart | ||
|
||
|
||
class BerkeleyBartTests(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self._sketch = sketchingpy.Sketch2D(500, 500) | ||
|
||
def test_parse_data_point(self): | ||
data_facade = draw_berkeley_bart.DataFacade(self._sketch) | ||
result = data_facade._parse_data_point({ | ||
'name': 'test', | ||
'code': 'te', | ||
'count': '1,234' | ||
}) | ||
self.assertEqual(result.get_name(), 'test') | ||
self.assertEqual(result.get_code(), 'te') | ||
self.assertEqual(result.get_count(), 1234) | ||
|
||
def test_get_line_length_zero(self): | ||
presenter = draw_berkeley_bart.StationVizPresenter(self._sketch) | ||
self.assertEqual(presenter._get_line_length(100, 0), draw_berkeley_bart.LINE_MIN_LEN) | ||
|
||
def test_get_line_length_max(self): | ||
presenter = draw_berkeley_bart.StationVizPresenter(self._sketch) | ||
self.assertEqual(presenter._get_line_length(100, 100), draw_berkeley_bart.LINE_MAX_LEN) | ||
|
||
def test_get_line_length_half(self): | ||
presenter = draw_berkeley_bart.StationVizPresenter(self._sketch) | ||
halfway = (draw_berkeley_bart.LINE_MAX_LEN + draw_berkeley_bart.LINE_MIN_LEN) / 2 | ||
self.assertEqual(presenter._get_line_length(100, 50), halfway) |