-
Notifications
You must be signed in to change notification settings - Fork 15
Lauren Steenkamp test #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,11 @@ def get_departure_airport(ticket_string: str): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Flight Number (JO234) can vary in length. You must find it relative to the hyphens. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # TODO: Write your code here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| departure_code = ticket_string.split("-")[2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return departure_code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def check_baggage_allowance(ticket_string: str): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -36,7 +40,22 @@ def check_baggage_allowance(ticket_string: str): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - For any other code: return "Standard - 0kg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # TODO: Write your code here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| check_baggage_allowance("FL-JO234-JNB-CPT-2023") |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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")) |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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")) |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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")) |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This debug print statement should be removed from the production code.
| print(flight_number) |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition direction_val / 2 != 0 is redundant with an else clause. Since the previous if checks for even, the elif for odd is unnecessary. This should be simplified to just else: for the odd case, with the "Invalid Flight" case handled separately (when extraction fails).
| 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 : | |
| print("Valid - Southbound") | |
| else: | |
| print("Invalid Flight") | |
| # Extract numeric part from flight_number | |
| import re | |
| match = re.search(r'(\d+)', flight_number) | |
| if match: | |
| number = int(match.group(1)) | |
| if number % 2 == 0: | |
| print("Valid - Northbound") | |
| else: | |
| print("Valid - Southbound") | |
| else: | |
| print("Invalid Flight") |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison i is int is incorrect. This checks if i is the int type itself, not if i is an instance of int. It should be if i.isdigit(): for string characters or use isinstance(i, int) if i were an integer. Additionally, direction_val is reset to 0 on each iteration inside the loop, which will cause incorrect behavior.
| 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 : | |
| print("Valid - Southbound") | |
| else: | |
| print("Invalid Flight") | |
| # Extract numeric part from flight_number (e.g., "JO234" -> "234") | |
| numeric_part = ''.join([c for c in flight_number if c.isdigit()]) | |
| if not numeric_part: | |
| print("Invalid Flight") | |
| return | |
| try: | |
| number = int(numeric_part) | |
| except ValueError: | |
| print("Invalid Flight") | |
| return | |
| if number % 2 == 0: | |
| print("Valid - Northbound") | |
| else: | |
| print("Valid - Southbound") |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function uses print() statements instead of returning values. According to the docstring, it should return strings like "Valid - Northbound", "Valid - Southbound", or "Invalid Flight", not print them. Replace all print() calls with return statements.
| 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 : | |
| print("Valid - Southbound") | |
| else: | |
| print("Invalid Flight") | |
| # Extract numeric part from flight_number | |
| numeric_part = ''.join(filter(str.isdigit, flight_number)) | |
| try: | |
| num = int(numeric_part) | |
| except ValueError: | |
| return "Invalid Flight" | |
| if num % 2 == 0: | |
| return "Valid - Northbound" | |
| else: | |
| return "Valid - Southbound" |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition direction_val / 2 == 0 checks if division equals 0, which would always be False for any positive number. This should use the modulo operator: direction_val % 2 == 0 to check if the number is even.
| 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 : | |
| print("Valid - Southbound") | |
| else: | |
| print("Invalid Flight") | |
| # Extract numeric part from flight_number | |
| import re | |
| match = re.search(r'\d+', flight_number) | |
| if match: | |
| direction_val = int(match.group()) | |
| if direction_val % 2 == 0: | |
| print("Valid - Northbound") | |
| else: | |
| print("Valid - Southbound") | |
| else: | |
| print("Invalid Flight") |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after # in the comment. Should be # TODO: for consistency with code style.
| #TODO: Write your code here | |
| # TODO: Write your code here |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The leap year logic is incorrect. The current implementation returns False for years divisible by 4 but not by 100 (line 111-112), which is wrong. According to the rules: if divisible by 4 AND NOT by 100, it should return True. If divisible by 100, check if divisible by 400. The logic should be: if year % 4 != 0: return False, elif year % 100 != 0: return True, else: return year % 400 == 0.
| return False | |
| elif year % 100 != 0 : | |
| return False | |
| else: | |
| if year % 400 != 0: | |
| return False | |
| return False | |
| elif year % 100 != 0: | |
| return True | |
| else: | |
| return year % 400 == 0 |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after # in the comment. Should be # TODO: for consistency with code style.
| #TODO: Write your code here | |
| # TODO: Write your code here |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reactor_status function is incomplete. According to the docstring (lines 143-145), it should handle multiple cases: CRITICAL (temp > 2000 OR radiation > 500), WARNING (temp between 1000-2000 AND radiation > 100), MAINTENANCE (temp < 500), and NORMAL (all other cases). Currently, only the "Sensor Error" case is implemented.
| return "Sensor Error" | |
| return "Sensor Error" | |
| elif temp > 2000 or radiation > 500: | |
| return "CRITICAL" | |
| elif 1000 <= temp <= 2000 and radiation > 100: | |
| return "WARNING" | |
| elif temp < 500: | |
| return "Maintenance Mode" | |
| else: | |
| return "Normal Operation" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,10 @@ | ||||||||||||||||||||||||||||
| import unittest | ||||||||||||||||||||||||||||
| from system_check import reactor_status | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+2
to
+3
|
||||||||||||||||||||||||||||
| from system_check import reactor_status |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing parentheses for the function call. It should be unittest.main() to execute the function.
| unittest.main | |
| unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function uses
print()statements instead of returning values. According to the docstring, it should return strings like "Economy - 20kg", not print them. Additionally, thereturnstatement on line 55 is inside the else block, so other branches don't return values. The function should return the formatted string in each branch instead of printing.