system check assessment#7
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements solutions for a Python assessment covering data parsing, algorithmic logic, and test-driven development. The submission includes implementations for five functions (flight ticket parsing functions, leap year logic, and reactor status monitoring) along with a required test file for the reactor status function.
Key Changes:
- Implemented flight ticket parsing functions (
get_departure_airport,check_baggage_allowance,validate_flight_number) - Implemented leap year calculation logic with modulo operations
- Implemented reactor status monitoring with multi-condition logic
- Created
test_reactor.pywith unit tests for the reactor status function
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| test_reactor.py | New test file containing TestReactor class with unit tests for reactor_status function, following unittest framework conventions |
| system_check.py | Implementations added for all five assessment functions, but includes debug code that should be removed and a critical bug in validate_flight_number |
| pycache/system_check.cpython-312.pyc | Compiled Python bytecode file that should not be committed to version control |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ticket_string = "FL-JO234-JNB-CPT-2023" | ||
| check_baggage_allowance(ticket_string) |
There was a problem hiding this comment.
Remove this test/debug code. Function definitions in a module should not include standalone function calls at the module level, as they execute on import and can cause unexpected side effects.
| ticket_string = "FL-JOABC-JNB-CPT" | ||
|
|
||
|
|
||
| validate_flight_number(ticket_string) |
There was a problem hiding this comment.
Remove this test/debug code. Function definitions in a module should not include standalone function calls at the module level, as they execute on import and can cause unexpected side effects.
|
|
||
| ticket = ticket_string[1] | ||
|
|
||
| ticket_num = ticket[-1] |
There was a problem hiding this comment.
This only checks the last character of the flight number, not the entire numeric portion. According to the docstring (line 62), you need to extract "the number portion (e.g., 234)" from "JO234". You should extract all trailing digits from the flight number string, not just the last character. For example, for "JO234", you need to extract "234" and check if it's even/odd, not just "4".
| else: | ||
| return False | ||
| else: | ||
| return True |
There was a problem hiding this comment.
Remove trailing whitespace at the end of this line.
| return True | |
| return True |
| else: | ||
| return "Normal Operation" | ||
|
|
||
|
|
There was a problem hiding this comment.
Remove this unnecessary blank line at the end of the file.
| ticket_string = "FL-JO234-JNB-CPT-2023" | ||
| get_departure_airport(ticket_string) |
There was a problem hiding this comment.
Remove this test/debug code. Function definitions in a module should not include standalone function calls at the module level, as they execute on import and can cause unexpected side effects.
| year = 2000 | ||
|
|
||
| is_leap_year(year) |
There was a problem hiding this comment.
Remove this test/debug code. Function definitions in a module should not include standalone function calls at the module level, as they execute on import and can cause unexpected side effects.
| return "Normal Operation" | ||
|
|
||
|
|
||
| reactor_status(-1, 50) |
There was a problem hiding this comment.
Remove this test/debug code. Function definitions in a module should not include standalone function calls at the module level, as they execute on import and can cause unexpected side effects.
| reactor_status(-1, 50) |
|
|
||
| ticket = ticket_string[1] | ||
|
|
||
| ticket_num = ticket[-1] | ||
|
|
||
| if not ticket_num.isdigit(): | ||
| return "Invalid Flight" | ||
|
|
||
| if int(ticket_num)%2 == 0: | ||
| return "Valid - Northbound" | ||
| elif int(ticket_num)%2 != 0: | ||
| return "Valid - Southbound" | ||
|
|
||
|
|
There was a problem hiding this comment.
Remove the unnecessary blank line. This creates inconsistent spacing in the function body.
| ticket = ticket_string[1] | |
| ticket_num = ticket[-1] | |
| if not ticket_num.isdigit(): | |
| return "Invalid Flight" | |
| if int(ticket_num)%2 == 0: | |
| return "Valid - Northbound" | |
| elif int(ticket_num)%2 != 0: | |
| return "Valid - Southbound" | |
| ticket = ticket_string[1] | |
| ticket_num = ticket[-1] | |
| if not ticket_num.isdigit(): | |
| return "Invalid Flight" | |
| if int(ticket_num)%2 == 0: | |
| return "Valid - Northbound" | |
| elif int(ticket_num)%2 != 0: | |
| return "Valid - Southbound" |
| return "Sensor Error" | ||
| elif temp > 2000 or radiation > 500: | ||
| return "CRITICAL" | ||
| elif 1000 <= temp <= 2000 and radiation > 100: |
There was a problem hiding this comment.
Test is always true, because of this condition.
No description provided.