Skip to content

Commit

Permalink
Merge pull request #18 from erunks/update-modem-reporting
Browse files Browse the repository at this point in the history
[BUG FIX]: Update ModemReporter
  • Loading branch information
erunks authored Jan 11, 2021
2 parents 41db566 + 719d37c commit fffd3f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ModemReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def report_events(self, events):
try:
self.connect_database()
sql = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES "
value_string = '(%s, %s, %s, %s)'
value_string = '("%s", %s, "%s", %s)'

event_datetime = None
value_list = []
Expand Down
10 changes: 5 additions & 5 deletions src/tests/ModemReporter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_report_events(self, connect_mock):
['Wed Sep 09 11:00:00 2020', 'Error (4)', 'The description'],
['Thu Sep 10 09:00:00 2020', 'Error (4)', 'The description']
]
SQL_QUERY = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES (The description, 4, 2020-09-09 11:00:00, False), (The description, 4, 2020-09-10 09:00:00, False)"
SQL_QUERY = 'INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES ("The description", 4, "2020-09-09 11:00:00", False), ("The description", 4, "2020-09-10 09:00:00", False)'
cursor_mock = MagicMock()
CONNECTION_MOCK.cursor.return_value = cursor_mock
connect_mock.return_value = CONNECTION_MOCK
Expand All @@ -161,7 +161,7 @@ def test_report_events_when_no_times_have_been_established(self, connect_mock):
['Time Not Established', 'Error (4)', 'The description'],
['Time Not Established', 'Error (4)', 'The description']
]
SQL_QUERY = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES (The description, 4, 2020-09-15 13:05:00, False), (The description, 4, 2020-09-15 13:05:00, False), (The description, 4, 2020-09-15 13:05:00, False)"
SQL_QUERY = 'INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES ("The description", 4, "2020-09-15 13:05:00", False), ("The description", 4, "2020-09-15 13:05:00", False), ("The description", 4, "2020-09-15 13:05:00", False)'
cursor_mock = MagicMock()
CONNECTION_MOCK.cursor.return_value = cursor_mock
connect_mock.return_value = CONNECTION_MOCK
Expand All @@ -182,7 +182,7 @@ def test_report_events_when_an_earlier_event_has_no_time_established(self, conne
['Wed Sep 09 11:00:00 2020', 'Error (4)', 'The description'],
['Thu Sep 10 09:00:00 2020', 'Error (4)', 'The description']
]
SQL_QUERY = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES (The description, 4, 2020-09-09 11:00:00, False), (The description, 4, 2020-09-09 11:00:00, False), (The description, 4, 2020-09-10 09:00:00, False)"
SQL_QUERY = 'INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES ("The description", 4, "2020-09-09 11:00:00", False), ("The description", 4, "2020-09-09 11:00:00", False), ("The description", 4, "2020-09-10 09:00:00", False)'
cursor_mock = MagicMock()
CONNECTION_MOCK.cursor.return_value = cursor_mock
connect_mock.return_value = CONNECTION_MOCK
Expand All @@ -197,13 +197,13 @@ def test_report_events_when_an_earlier_event_has_no_time_established(self, conne
CONNECTION_MOCK.close.assert_called_once()

@patch('mysql.connector.connect')
def test_report_events_when_an_later_event_has_no_time_established(self, connect_mock):
def test_report_events_when_a_later_event_has_no_time_established(self, connect_mock):
EVENTS = [
['Wed Sep 09 11:00:00 2020', 'Error (4)', 'The description'],
['Thu Sep 10 09:00:00 2020', 'Error (4)', 'The description'],
['Time Not Established', 'Error (4)', 'The description']
]
SQL_QUERY = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES (The description, 4, 2020-09-09 11:00:00, False), (The description, 4, 2020-09-10 09:00:00, False), (The description, 4, 2020-09-10 09:00:00, False)"
SQL_QUERY = 'INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES ("The description", 4, "2020-09-09 11:00:00", False), ("The description", 4, "2020-09-10 09:00:00", False), ("The description", 4, "2020-09-10 09:00:00", False)'
cursor_mock = MagicMock()
CONNECTION_MOCK.cursor.return_value = cursor_mock
connect_mock.return_value = CONNECTION_MOCK
Expand Down

0 comments on commit fffd3f4

Please sign in to comment.