Lauren Steenkamp test#8
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request attempts to implement solutions for a Python programming assessment involving string parsing, algorithmic logic, and test-driven development. The PR includes implementations for five functions and a test file for the reactor status functionality.
Key Changes:
- Implementation of
get_departure_airport()to extract airport codes from ticket strings - Implementation of
check_baggage_allowance(),validate_flight_number(),is_leap_year(), and partial implementation ofreactor_status() - Creation of
test_reactor.pytest file (incomplete)
Reviewed changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated 20 comments.
Show a summary per file
| File | Description |
|---|---|
| test_reactor.py | New test file created for reactor_status function, but contains multiple syntax errors and incomplete test implementation |
| system_check.py | Implements solutions for 5 programming challenges with critical bugs in logic, incorrect use of print vs return, and incomplete implementations |
| pycache/test_system_check.cpython-312.pyc | Compiled bytecode (no review needed) |
| pycache/test_reactor.cpython-312.pyc | Compiled bytecode (no review needed) |
| pycache/system_check.cpython-312.pyc | Compiled bytecode (no review needed) |
Critical Issues Found:
- Multiple syntax errors in test_reactor.py (missing function arguments, incorrect string comparison, missing parentheses)
- Functions using print() instead of return statements as specified in docstrings
- Incorrect leap year logic implementation
- Incomplete reactor_status function
- Logic errors in validate_flight_number (wrong operator usage, incorrect type checking)
- Debug/test code left in production file
Comments suppressed due to low confidence (2)
test_reactor.py:9
- Comparison of constants; use 'True' or 'False' instead.
if '__name__' == '__main__':
test_reactor.py:9
- Testing a constant will always give the same result.
if '__name__' == '__main__':
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
| if '__name__' == '__main__': | ||
| unittest.main No newline at end of file |
There was a problem hiding this comment.
The assertEqual call is missing both arguments. It should compare an actual value with an expected value, e.g., self.assertEqual(reactor_status(100, 50), "Maintenance Mode").
| ) | |
| if '__name__' == '__main__': | |
| unittest.main | |
| reactor_status(100, 50), "Maintenance Mode" | |
| ) | |
| if __name__ == '__main__': | |
| unittest.main() |
| if '__name__' == '__main__': | ||
| unittest.main No newline at end of file |
There was a problem hiding this comment.
The condition check is incorrect. '__name__' is a string literal, not a variable. It should be if __name__ == '__main__': (without quotes around __name__).
| if '__name__' == '__main__': | |
| unittest.main | |
| if __name__ == '__main__': | |
| unittest.main() |
| # TODO: Write your code here | ||
| pass | ||
| flight_number = ticket_string.split("-")[1] | ||
| print(flight_number) |
There was a problem hiding this comment.
This debug print statement should be removed from the production code.
| print(flight_number) |
| for i in flight_number: | ||
| direction_val = 0 | ||
| if i is int: | ||
| direction_val += i | ||
|
|
||
| if direction_val / 2 == 0 : | ||
| print("Valid - Northbound") | ||
|
|
||
| elif direction_val / 2 != 0 : |
There was a problem hiding this comment.
The variable direction_val is being initialized inside the loop on each iteration. It should be initialized once before the loop starts: move this line before line 75.
| for i in flight_number: | |
| direction_val = 0 | |
| if i is int: | |
| direction_val += i | |
| if direction_val / 2 == 0 : | |
| print("Valid - Northbound") | |
| elif direction_val / 2 != 0 : | |
| direction_val = 0 | |
| for i in flight_number: | |
| if i.isdigit(): | |
| direction_val += int(i) | |
| if direction_val % 2 == 0 and direction_val != 0: | |
| print("Valid - Northbound") | |
| elif direction_val % 2 != 0: |
| validate_flight_number("FL-JO234-JNB-CPT-2023") | ||
|
|
There was a problem hiding this comment.
This function call should be removed. It appears to be debugging/test code left in the production file and will execute every time the module is imported.
| validate_flight_number("FL-JO234-JNB-CPT-2023") |
| pass | ||
|
|
||
|
|
||
| #TODO: Write your code here |
There was a problem hiding this comment.
Missing space after # in the comment. Should be # TODO: for consistency with code style.
| #TODO: Write your code here | |
| # TODO: Write your code here |
| if ticket_string.split("-")[0] == "EC": | ||
| baggage_allowance = 20 | ||
| print("Economy - 20kg") | ||
| elif ticket_string.split("-")[0] == "BS": | ||
| baggage_allowance = 40 | ||
| print("Business - 40kg") | ||
| elif ticket_string.split("-")[0] == "FL": | ||
| baggage_allowance = 60 | ||
| print("First Class - 60kg") | ||
| else: | ||
| baggage_allowance = 0 | ||
| print("Standard - 0kg") | ||
| return baggage_allowance | ||
| check_baggage_allowance("FL-JO234-JNB-CPT-2023") |
There was a problem hiding this comment.
Variable baggage_allowance is not used.
| if ticket_string.split("-")[0] == "EC": | |
| baggage_allowance = 20 | |
| print("Economy - 20kg") | |
| elif ticket_string.split("-")[0] == "BS": | |
| baggage_allowance = 40 | |
| print("Business - 40kg") | |
| elif ticket_string.split("-")[0] == "FL": | |
| baggage_allowance = 60 | |
| print("First Class - 60kg") | |
| else: | |
| baggage_allowance = 0 | |
| print("Standard - 0kg") | |
| return baggage_allowance | |
| check_baggage_allowance("FL-JO234-JNB-CPT-2023") | |
| class_code = ticket_string.split("-")[0] | |
| if class_code == "EC": | |
| return "Economy - 20kg" | |
| elif class_code == "BS": | |
| return "Business - 40kg" | |
| elif class_code == "FL": | |
| return "First Class - 60kg" | |
| else: | |
| return "Standard - 0kg" | |
| print(check_baggage_allowance("FL-JO234-JNB-CPT-2023")) |
| baggage_allowance = 20 | ||
| print("Economy - 20kg") | ||
| elif ticket_string.split("-")[0] == "BS": | ||
| baggage_allowance = 40 | ||
| print("Business - 40kg") | ||
| elif ticket_string.split("-")[0] == "FL": | ||
| baggage_allowance = 60 | ||
| print("First Class - 60kg") | ||
| else: | ||
| baggage_allowance = 0 | ||
| print("Standard - 0kg") | ||
| return baggage_allowance | ||
| check_baggage_allowance("FL-JO234-JNB-CPT-2023") |
There was a problem hiding this comment.
Variable baggage_allowance is not used.
| baggage_allowance = 20 | |
| print("Economy - 20kg") | |
| elif ticket_string.split("-")[0] == "BS": | |
| baggage_allowance = 40 | |
| print("Business - 40kg") | |
| elif ticket_string.split("-")[0] == "FL": | |
| baggage_allowance = 60 | |
| print("First Class - 60kg") | |
| else: | |
| baggage_allowance = 0 | |
| print("Standard - 0kg") | |
| return baggage_allowance | |
| check_baggage_allowance("FL-JO234-JNB-CPT-2023") | |
| return "Economy - 20kg" | |
| elif ticket_string.split("-")[0] == "BS": | |
| return "Business - 40kg" | |
| elif ticket_string.split("-")[0] == "FL": | |
| return "First Class - 60kg" | |
| else: | |
| return "Standard - 0kg" | |
| print(check_baggage_allowance("FL-JO234-JNB-CPT-2023")) |
| baggage_allowance = 20 | ||
| print("Economy - 20kg") | ||
| elif ticket_string.split("-")[0] == "BS": | ||
| baggage_allowance = 40 | ||
| print("Business - 40kg") | ||
| elif ticket_string.split("-")[0] == "FL": | ||
| baggage_allowance = 60 | ||
| print("First Class - 60kg") | ||
| else: | ||
| baggage_allowance = 0 | ||
| print("Standard - 0kg") | ||
| return baggage_allowance | ||
| check_baggage_allowance("FL-JO234-JNB-CPT-2023") |
There was a problem hiding this comment.
Variable baggage_allowance is not used.
| baggage_allowance = 20 | |
| print("Economy - 20kg") | |
| elif ticket_string.split("-")[0] == "BS": | |
| baggage_allowance = 40 | |
| print("Business - 40kg") | |
| elif ticket_string.split("-")[0] == "FL": | |
| baggage_allowance = 60 | |
| print("First Class - 60kg") | |
| else: | |
| baggage_allowance = 0 | |
| print("Standard - 0kg") | |
| return baggage_allowance | |
| check_baggage_allowance("FL-JO234-JNB-CPT-2023") | |
| return "Economy - 20kg" | |
| elif ticket_string.split("-")[0] == "BS": | |
| return "Business - 40kg" | |
| elif ticket_string.split("-")[0] == "FL": | |
| return "First Class - 60kg" | |
| else: | |
| return "Standard - 0kg" | |
| print(check_baggage_allowance("FL-JO234-JNB-CPT-2023")) |
| from system_check import reactor_status | ||
|
|
There was a problem hiding this comment.
Import of 'reactor_status' is not used.
| from system_check import reactor_status |
No description provided.