Skip to content

Commit

Permalink
Fixing formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kschmader committed Jul 19, 2024
1 parent 8a748c0 commit 42c22ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/alogamous/warning_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ def read_log_line(self, line):
line_list = line.split(" ")
# List should have format [date, timestamp, -, root, -, log message type, -, first word of message...]
if line_list[5].lower() == "warning":
self.count += (1)

self.count += 1

def report(self, out_stream):
if self.count == 0:
out_stream.write("\n" + "No Warnings were detected.")
elif self.count == 1:
out_stream.write("\n" + "1 Warning was detected.")
else:
out_stream.write("\n" + str(self.count) + " Warnings were detected.")
out_stream.write("\n" + str(self.count) + " Warnings were detected.")
7 changes: 2 additions & 5 deletions tests/warning_analyzer_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import io

from src.alogamous import analyzer, warning_analyzer
import data


def test_warning_count():
in_stream = io.StringIO("""2024-06-20 11:00:18,185 - root - INFO - Kafka reading from start of day 2024-06-20 05:00:00+00:00 on topic internal from kafka.servers:9092
Expand All @@ -14,7 +14,4 @@ def test_warning_count():
2024-06-20 17:25:08,029 - root - ERROR - Exception in message handler <bound method TrackingService.method of <app.tracking_service.TrackingService object at 0x7feba0d0>> TrackingService.on_order_change() missing 1 required positional argument: 'order_identifier'""")
out_stream = io.StringIO()
analyzer.analyze_log_stream([warning_analyzer.WarningAnalyzer()], in_stream, out_stream)
assert (
out_stream.getvalue()
== "\n2 Warnings were detected."
)
assert out_stream.getvalue() == "\n2 Warnings were detected."

0 comments on commit 42c22ae

Please sign in to comment.