diff --git a/coordinates/coordinates.json.example b/coordinates/coordinates.json.example new file mode 100644 index 00000000..8ec22adc --- /dev/null +++ b/coordinates/coordinates.json.example @@ -0,0 +1,357 @@ +{ + "defaults": { + "font_name": "4x6" + }, + "bases": { + "1B": { + "x": 24, + "y": 24, + "size": 6 + }, + "2B": { + "x": 19, + "y": 19, + "size": 6 + }, + "3B": { + "x": 14, + "y": 24, + "size": 6 + } + }, + "final": { + "inning": { + "x": 16, + "y": 20 + }, + "scrolling_text": { + "x": 0, + "y": 31, + "width": 32 + }, + "nohit_text": { + "x": 10, + "y": 26 + } + }, + "inning": { + "break": { + "number": { + "x": 11, + "y": 29 + }, + "text": { + "x": 11, + "y": 22 + }, + "due_up": { + "due": { + "x": 33, + "y": 33 + }, + "up": { + "x": 33, + "y": 33 + }, + "divider": { + "draw": false, + "x": 33, + "y_start": 33, + "y_end": 33 + }, + "leadoff": { + "x": 33, + "y": 33 + }, + "on_deck": { + "x": 33, + "y": 33 + }, + "in_hole": { + "x": 33, + "y": 33 + } + } + }, + "number": { + "x": 32, + "y": 20 + }, + "arrow": { + "size": 2, + "up": { + "x_offset": -4, + "y_offset": -4 + }, + "down": { + "x_offset": -4, + "y_offset": -3 + } + } + }, + "outs": { + "1": { + "x": 1, + "y": 26, + "size": 2, + "nohit": { + "x": 1, + "y": 28, + "size": 2 + }, + "perfect_game": { + "x": 1, + "y": 28, + "size": 2 + } + }, + "2": { + "x": 5, + "y": 26, + "size": 2, + "nohit": { + "x": 5, + "y": 28, + "size": 2 + }, + "perfect_game": { + "x": 5, + "y": 28, + "size": 2 + } + }, + "3": { + "x": 9, + "y": 26, + "size": 2, + "nohit": { + "x": 9, + "y": 28, + "size": 2 + }, + "perfect_game": { + "x": 9, + "y": 28, + "size": 2 + } + } + }, + "atbat": { + "batter": { + "x": 33, + "y": 33, + "width": 10 + }, + "pitcher": { + "x": 33, + "y": 33, + "width": 12 + }, + "pitch": { + "font_name": "4x6", + "x": 1, + "y": 50, + "enabled": false, + "mph": false, + "desc_length": "Short" + }, + "pitch_count": { + "font_name": "4x6", + "x": 1, + "y": 50, + "enabled": false, + "append_pitcher_name": false + }, + "loop": 16, + "strikeout": { + "x": 33, + "y": 33 + } + }, + "batter_count": { + "x": 1, + "y": 23, + "nohit": { + "x": 1, + "y": 21 + }, + "perfect_game": { + "x": 1, + "y": 21 + } + }, + "nohitter": { + "x": 1, + "y": 27, + "innings_until_display": 5 + }, + "pregame": { + "scrolling_text": { + "x": 0, + "y": 31, + "width": 32, + "warmup": { + "x": 0, + "y": 31, + "width": 32 + } + }, + "start_time": { + "x": 16, + "y": 20 + }, + "warmup_text": { + "x": 16, + "y": 20 + } + }, + "standings": { + "font_name": "4x6", + "start": 1, + "offset": 6, + "height": 30, + "width": 32, + "divider": { + "x": 13 + }, + "stat_title": { + "x": 28 + }, + "team": { + "name": { + "x": 1 + }, + "record": { + "x": 15 + }, + "games_back": { + "x": 64 + } + }, + "postseason": { + "matchup_y_gap": 12, + "series_x_gap": 32, + "wc_x_start": 3, + "wc_y_start": 12, + "ds_a_y_start": 51, + "__comment": "all other coords are based off wild card position" + } + }, + "status": { + "text": { + "x": 16, + "y": 20, + "short_text": true + }, + "scrolling_text": { + "x": 0, + "y": 31, + "width": 32 + } + }, + "teams": { + "background": { + "away": { + "width": 32, + "height": 7, + "x": 0, + "y": 0 + }, + "home": { + "width": 32, + "height": 7, + "x": 0, + "y": 7 + } + }, + "accent": { + "away": { + "width": 1, + "height": 7, + "x": 0, + "y": 0 + }, + "home": { + "width": 1, + "height": 7, + "x": 0, + "y": 7 + } + }, + "name": { + "away": { + "x": 3, + "y": 6 + }, + "home": { + "x": 3, + "y": 13 + } + }, + "runs": { + "runs_hits_errors": { + "show": false, + "compress_digits": true, + "spacing": 2 + }, + "away": { + "x": 31, + "y": 6 + }, + "home": { + "x": 31, + "y": 13 + } + } + }, + "offday": { + "scrolling_text": { + "x": 0, + "y": 30, + "width": 32 + }, + "time": { + "x": 16, + "y": 23 + }, + "conditions": { + "x": 0, + "y": -2 + }, + "temperature": { + "x": 25, + "y": 12 + }, + "wind_speed": { + "x": 0, + "y": -2 + }, + "wind_dir": { + "x": 0, + "y": -2 + }, + "wind": { + "x": 0, + "y": -2 + }, + "weather_icon": { + "x": 1, + "y": 1, + "width": 15, + "height": 15 + } + }, + "network": { + "font_name": "4x6", + "background": { + "width": 7, + "height": 7, + "x": 25, + "y": 25 + }, + "text": { + "x": 29, + "y": 31 + } + } +} diff --git a/coordinates/w128h32.json.example b/coordinates/w128h32.json.example index d3c59047..9a66fd6c 100644 --- a/coordinates/w128h32.json.example +++ b/coordinates/w128h32.json.example @@ -209,8 +209,8 @@ } }, "standings": { - "__comment__": "Delete this next line and make offset 8 to make the font much larger but only display 4 teams", "font_name": "4x6", + "start": 0, "offset": 6, "height": 32, "width": 128, diff --git a/coordinates/w128h64.json.example b/coordinates/w128h64.json.example index 52fe6f11..d0cdc8d0 100644 --- a/coordinates/w128h64.json.example +++ b/coordinates/w128h64.json.example @@ -188,6 +188,7 @@ } }, "standings": { + "font_name": "4x6", "start": 1, "offset": 12, "height": 60, diff --git a/coordinates/w32h32.json.example b/coordinates/w32h32.json.example index f872886a..aa88651c 100644 --- a/coordinates/w32h32.json.example +++ b/coordinates/w32h32.json.example @@ -206,6 +206,8 @@ } }, "standings": { + "font_name": "4x6", + "start": 0, "offset": 6, "height": 30, "width": 32, @@ -225,6 +227,14 @@ "games_back": { "x": 64 } + }, + "postseason": { + "matchup_y_gap": 12, + "series_x_gap": 32, + "wc_x_start": 3, + "wc_y_start": 12, + "ds_a_y_start": 51, + "__comment": "all other coords are based off wild card position" } }, "status": { diff --git a/coordinates/w64h32.json.example b/coordinates/w64h32.json.example index d36bd9e6..008a7043 100644 --- a/coordinates/w64h32.json.example +++ b/coordinates/w64h32.json.example @@ -183,6 +183,8 @@ } }, "standings": { + "font_name": "4x6", + "start": 0, "offset": 6, "height": 30, "width": 64, diff --git a/coordinates/w64h64.json.example b/coordinates/w64h64.json.example index bde2213a..9370b104 100644 --- a/coordinates/w64h64.json.example +++ b/coordinates/w64h64.json.example @@ -105,7 +105,15 @@ }, "batter_count": { "x": 46, - "y": 46 + "y": 46, + "nohit": { + "x": 46, + "y": 46 + }, + "perfect_game": { + "x": 46, + "y": 46 + } }, "nohitter": { "x": 30, diff --git a/tests/test_validate_coordinate_examples.py b/tests/test_validate_coordinate_examples.py new file mode 100644 index 00000000..11990b20 --- /dev/null +++ b/tests/test_validate_coordinate_examples.py @@ -0,0 +1,37 @@ +import json, os, re, unittest + +from validate_config import upsert_config + +class TestValidateCoordinateExamples(unittest.TestCase): + + COORDINATES_DIR = "coordinates" + REFERENCE_FILENAME = "coordinates.json.example" + REFERENCE_PATH = os.path.join(COORDINATES_DIR, REFERENCE_FILENAME) + SCHEMA_PATHS = [path for path in os.listdir(COORDINATES_DIR) if re.match(r'w[0-9]+h[0-9]+\.json\.example', path)] + + def __test_coordinate_schema(self, schema_path): + reference = self.__load_schema(self.REFERENCE_PATH) + schema = self.__load_schema(schema_path) + + (changed, _result, changes) = upsert_config(schema, reference) + + self.assertEqual(changes, { "add": [], "delete": []}) + self.assertFalse(changed) + + def __load_schema(self, schema_path): + with open(schema_path) as schema_file: + schema = json.load(schema_file) + + return schema + + def test_all_schemas(self): + ''' + This tests ALL schemas matching the regex /w[0-9]+h[0-9]+\.json\.example/ in the coordinates directory. + + By doing it this way, if someone adds support for a new matrix size, the tests will automatically run for it. + ''' + + for path in self.SCHEMA_PATHS: + with self.subTest(): + schema_path = os.path.join(self.COORDINATES_DIR, path) + self.__test_coordinate_schema(schema_path)