Skip to content

Commit

Permalink
Revert adding a separate notification level for check-ins
Browse files Browse the repository at this point in the history
This change will be part of another PR as the details of #280 are still
being figured out.
  • Loading branch information
jdholtz committed Jul 4, 2024
1 parent 1a05b84 commit 47bbb82
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
9 changes: 3 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ If there is no "Upgrading" header for that version, no post-upgrade actions need

## Upcoming
### New Features
- Two new [notification levels](CONFIGURATION.md#notification-level) were added
- A separate notification level for successful check-in messages was added which only includes successful check-ins
and error messages ([#280](https://github.com/jdholtz/auto-southwest-check-in/issues/280))
- A notification level for notices (non-critical warnings) was added, which includes driver timeouts and Too Many Requests
errors during logins. This is the lowest notification level offered
- A new [notification level](CONFIGURATION.md#notification-level) for notices (non-critical warnings) was added, which includes
driver timeouts and Too Many Requests errors during logins. This is the lowest notification level offered
- The default configuration is still the same. Refer to the [notification level configuration](CONFIGURATION.md#notification-level)
for more details on the levels
- If you have manually set `notification_level` in your config.json, see the "Upgrading" header for how to adjust it for the
Expand All @@ -23,7 +20,7 @@ checking many accounts and reservations at once

### Upgrading
- If you manually set `notification_level` in your configuration, it will need to be adjusted accordingly.
- If it was set to `2` (error messages only), it needs to be set to `4`
- If it was set to `2` (error messages only), it needs to be set to `3`
- If it was set to `1` (all messages), it needs to be set to `2`
- Refer to the [notification level configuration](CONFIGURATION.md#notification-level) for more details on the levels

Expand Down
5 changes: 2 additions & 3 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ You can also select the level of notifications you want to receive.
```
`Level 1`: Receive notices of skipped reservation retrievals due to driver timeouts and Too Many Requests errors
during logins as well as all messages in later levels.\
`Level 2`: Receive successful scheduling messages, lower fare messages, and all messages in later levels.\
`Level 3`: Receive successful check-in messages and all messages in later levels.\
`Level 4`: Receive only error messages (failed scheduling and check-ins).
`Level 2`: Receive successful scheduling and check-in messages, lower fare messages, and all messages in later levels.\
`Level 3`: Receive only error messages (failed scheduling and check-ins).

### Notification 24 Hour Time
Default: false \
Expand Down
2 changes: 1 addition & 1 deletion lib/notification_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def successful_checkin(self, boarding_pass: Dict[str, Any], flight: Flight) -> N
)

logger.debug("Sending successful check-in notification...")
self.send_notification(success_message, NotificationLevel.CHECKIN)
self.send_notification(success_message, NotificationLevel.INFO)

def failed_checkin(self, error: RequestError, flight: Flight) -> None:
error_message = (
Expand Down
3 changes: 1 addition & 2 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ class DriverTimeoutError(Exception):
class NotificationLevel(IntEnum):
NOTICE = 1
INFO = 2
CHECKIN = 3
ERROR = 4
ERROR = 3


def is_truthy(arg: Union[bool, int, str]) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_merge_globals_merges_all_global_config_options(self) -> None:
{"notification_24_hour_time": "invalid"},
{"notification_level": "invalid"},
{"notification_level": -1},
{"notification_level": 5},
{"notification_level": 4},
{"notification_urls": None},
{"retrieval_interval": "invalid"},
],
Expand All @@ -100,7 +100,7 @@ def test_parse_config_sets_the_correct_config_values(self) -> None:
assert test_config.check_fares is False
assert test_config.healthchecks_url == "test_healthchecks"
assert test_config.notification_24_hour_time is False
assert test_config.notification_level == NotificationLevel.CHECKIN
assert test_config.notification_level == NotificationLevel.ERROR
assert test_config.notification_urls == ["test_url"]
assert test_config.retrieval_interval == 30 * 60 * 60

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_notification_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_successful_checkin_sends_notification_for_check_in(
},
mock_flight,
)
assert mock_send_notification.call_args[0][1] == NotificationLevel.CHECKIN
assert mock_send_notification.call_args[0][1] == NotificationLevel.INFO

def test_successful_checkin_does_not_include_notification_for_lap_child(
self, mocker: MockerFixture
Expand All @@ -131,7 +131,7 @@ def test_successful_checkin_does_not_include_notification_for_lap_child(
)
assert "John got A1!" in mock_send_notification.call_args[0][0]
assert "Lap Child" not in mock_send_notification.call_args[0][0]
assert mock_send_notification.call_args[0][1] == NotificationLevel.CHECKIN
assert mock_send_notification.call_args[0][1] == NotificationLevel.INFO

def test_failed_checkin_sends_error_notification(self, mocker: MockerFixture) -> None:
mock_send_notification = mocker.patch.object(NotificationHandler, "send_notification")
Expand Down

0 comments on commit 47bbb82

Please sign in to comment.