diff --git a/.github/workflows/pyinstaller-build.yml b/.github/workflows/pyinstaller-build.yml index eb43ec4..f787135 100644 --- a/.github/workflows/pyinstaller-build.yml +++ b/.github/workflows/pyinstaller-build.yml @@ -4,7 +4,7 @@ name: Build executeable env: - semver: 1.10.0.${{ github.run_number }} + semver: 1.10.1.${{ github.run_number }} python-version: 3.8 KIVY_GL_BACKEND: 'angle_sdl2' GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/requirements.txt b/requirements.txt index ceafa61..ae83741 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,6 @@ gpxpy == 1.4.2 #gpx output Kivy == 2.0.0 #gui kivy-garden.contextmenu == 0.1.0.dev1 #app context menu openpyxl == 3.0.7 #xlsx support -pyinstaller == 4.3 #compilation -requests == 2.25.1 +pyinstaller == 4.10 #compilation +requests == 2.25.1 #version checking semantic-version == 2.8.5 #semantic version comparing diff --git a/src/ham/util/validator.py b/src/ham/util/validator.py index 3a069fa..ef45642 100644 --- a/src/ham/util/validator.py +++ b/src/ham/util/validator.py @@ -14,6 +14,9 @@ class Validator: + MAX_MEDIUM_NAME_LENGTH = 8 + MAX_SHORT_NAME_LENGTH = 7 + def __init__(self): self._radio_channel_template = RadioChannelDefault.create_empty() self._digital_contact_template = DmrContactDefault.create_empty() @@ -75,7 +78,21 @@ def validate_radio_channel(self, cols, line_num, file_name, digital_contacts, zo return errors channel = RadioChannel(cols, None, None) - if channel.short_name.fmt_val().lower() in self._short_names.keys(): + + if len(channel.medium_name.fmt_val()) > self.MAX_MEDIUM_NAME_LENGTH: + err = ValidationError(f"Line {line_num} '{channel.medium_name.get_alias(radio_types.DEFAULT)}' greater than {self.MAX_MEDIUM_NAME_LENGTH} characters in length", line_num, file_name) + logging.debug(err.message) + errors.append(err) + if len(channel.short_name.fmt_val()) > self.MAX_SHORT_NAME_LENGTH: + err = ValidationError(f"Line {line_num} '{channel.short_name.get_alias(radio_types.DEFAULT)}' greater than {self.MAX_MEDIUM_NAME_LENGTH} characters in length", line_num, file_name) + logging.debug(err.message) + errors.append(err) + + if channel.short_name.fmt_val() is None: + err = ValidationError(f"'medium_name' column cannot be empty", line_num, file_name) + logging.debug(err.message) + errors.append(err) + elif channel.short_name.fmt_val().lower() in self._short_names.keys(): err = ValidationError( f"Collision in {channel.short_name.get_alias(radio_types.DEFAULT)} " f"(value: `{channel.short_name.fmt_val()}`) found with line" @@ -86,7 +103,11 @@ def validate_radio_channel(self, cols, line_num, file_name, digital_contacts, zo else: self._short_names[channel.short_name.fmt_val().lower()] = line_num - if channel.medium_name.fmt_val().lower() in self._medium_names.keys(): + if channel.medium_name.fmt_val() is None: + err = ValidationError(f"'medium_name' column cannot be empty", line_num, file_name) + logging.debug(err.message) + errors.append(err) + elif channel.medium_name.fmt_val().lower() in self._medium_names.keys(): err = ValidationError( f"Collision in {channel.medium_name.get_alias(radio_types.DEFAULT)} " f"(value: `{channel.medium_name.fmt_val()}`) found with line" @@ -97,7 +118,11 @@ def validate_radio_channel(self, cols, line_num, file_name, digital_contacts, zo else: self._medium_names[channel.medium_name.fmt_val().lower()] = line_num - if channel.name.fmt_val().lower() in self._long_names.keys(): + if channel.name.fmt_val() is None: + err = ValidationError(f"'name' column cannot be empty", line_num, file_name) + logging.debug(err.message) + errors.append(err) + elif channel.name.fmt_val().lower() in self._long_names.keys(): err = ValidationError( f"Collision in {channel.name.get_alias(radio_types.DEFAULT)} " f"(value: `{channel.name.fmt_val()}`) found with line" @@ -172,7 +197,6 @@ def _validate_generic(self, cols, line_num, file_name, needed_cols_dict_gen): for val in needed_cols_dict_gen.values(): if not isinstance(val, DataColumn): - logging.debug(f"Skipping adding `{val}` to needed cols") continue needed_cols[val.get_alias(radio_types.DEFAULT)] = val diff --git a/test/test_validator.py b/test/test_validator.py index b4750e8..fff0588 100644 --- a/test/test_validator.py +++ b/test/test_validator.py @@ -194,3 +194,9 @@ def test_validate_bad_long(self): self.assertEqual(len(errors), 1) found = errors[0].args[0].find('Longitude must be between') self.assertEqual(found, 0) + + def test_name_missing(self): + self.radio_cols['name'] = '' + errors = self.validator.validate_radio_channel(self.radio_cols, 1, 'LAT_LONG_UNITTEST', {}, {}) + self.assertEqual(len(errors), 1) +