Mthunzy#1
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements solutions for a Python coding assessment involving flight ticket parsing, leap year calculations, and reactor status monitoring. The changes include function implementations in system_check.py and creation of a test file test_reactor.py.
Key Changes:
- Implemented four string parsing functions for flight ticket processing (departure airport, baggage allowance, flight number validation)
- Added leap year calculation logic using modulo operations
- Implemented reactor status monitoring with temperature and radiation checks
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 13 comments.
| File | Description |
|---|---|
| test_reactor.py | Creates empty TestReactor class (missing required test implementations) |
| system_check.py | Implements all five required functions with logic for ticket parsing, leap year detection, and reactor monitoring |
| pycache/system_check.cpython-310.pyc | Compiled Python bytecode (auto-generated from system_check.py changes) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if temp < 500: | ||
| return "Maintenance Mode" | ||
| return "Normal Operation" | ||
| pass |
There was a problem hiding this comment.
Unreachable code: the pass statement on line 146 will never execute because the function returns on line 145. Remove this line to clean up the code.
| pass |
| if year%4 == 0: | ||
| if year%100 == 0: | ||
| if year%400 == 0: | ||
| return True | ||
| return False | ||
| return True | ||
| return False |
There was a problem hiding this comment.
Missing spaces around the modulo operator. According to PEP 8 style guidelines, binary operators should have spaces around them. Change year%4 to year % 4, year%100 to year % 100, and year%400 to year % 400 for better readability.
| # TODO: Write your code here | ||
| splitted_ticket = ticket_string.split("-") | ||
| return splitted_ticket[2] | ||
| pass |
There was a problem hiding this comment.
Unreachable code: the pass statement on line 23 will never execute because the function returns on line 22. Remove this line to clean up the code.
| return True | ||
| return False | ||
| # TODO: Write your code here | ||
| pass |
There was a problem hiding this comment.
Unreachable code: the pass statement on line 104 will never execute because the function returns on lines 96-102. Remove this line to clean up the code.
| pass |
| class TestReactor: | ||
| def __int__(self): | ||
| pass No newline at end of file |
There was a problem hiding this comment.
The TestReactor class is empty and doesn't contain any test methods. According to the requirements in system_check.py (lines 117-118), this class should implement TDD tests for the reactor_status function. The class should inherit from unittest.TestCase and include test methods for the various reactor status conditions (Sensor Error, CRITICAL, WARNING, Maintenance Mode, and Normal Operation).
| t_number = ticket_number[-1] | ||
|
|
||
| if t_number.isdigit(): | ||
| if int(t_number)%2 == 0: | ||
| return "Valid - Northbound" | ||
| else: | ||
| return "Valid - Southbound" |
There was a problem hiding this comment.
The logic only checks the last digit of the flight number (ticket_number[-1]) instead of extracting and checking the entire numeric portion. For example, in "JO234", this code checks if "4" is even/odd, but it should check if "234" is even/odd. Extract the numeric part properly (e.g., using ticket_number[2:] for "JO234") and convert it to an integer before checking.
| t_number = ticket_number[-1] | |
| if t_number.isdigit(): | |
| if int(t_number)%2 == 0: | |
| return "Valid - Northbound" | |
| else: | |
| return "Valid - Southbound" | |
| # Extract numeric portion from flight number (e.g., "JO234" -> "234") | |
| numeric_part = ''.join(filter(str.isdigit, ticket_number)) | |
| if numeric_part: | |
| try: | |
| num = int(numeric_part) | |
| if num % 2 == 0: | |
| return "Valid - Northbound" | |
| else: | |
| return "Valid - Southbound" | |
| except ValueError: | |
| return "Invalid Flight" |
| Flight Number (JO234) can vary in length. You must find it relative to the hyphens. | ||
| """ | ||
| # TODO: Write your code here | ||
| splitted_ticket = ticket_string.split("-") |
There was a problem hiding this comment.
The ticket string is split multiple times across different functions (lines 21, 41, 64). Consider adding input validation and error handling for the split operation. If the ticket string doesn't contain the expected number of hyphens, the code will raise an IndexError. This would improve robustness.
| elif cl == "FL": | ||
| return "First Class - 60kg" | ||
| return "Standard - 0kg" | ||
| pass |
There was a problem hiding this comment.
Unreachable code: the pass statement on line 50 will never execute because the function returns on line 49. Remove this line to clean up the code.
| pass |
| return "Valid - Southbound" | ||
| else: | ||
| return "Invalid Flight" | ||
| pass |
There was a problem hiding this comment.
Unreachable code: the pass statement on line 75 will never execute because the function returns on line 74. Remove this line to clean up the code.
| pass |
| return "Sensor Error" | ||
| if temp > 2000 or radiation > 500: | ||
| return "CRITICAL" | ||
| if (temp >= 1000 and temp <= 2000) and radiation > 100: |
There was a problem hiding this comment.
Test is always true, because of this condition.
| if (temp >= 1000 and temp <= 2000) and radiation > 100: | |
| if temp >= 1000 and radiation > 100: |
Mthunzi Ntombela