Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
Binary file added __pycache__/system_check.cpython-313.pyc
Binary file not shown.
Binary file added __pycache__/test_reactor.cpython-313.pyc
Binary file not shown.
Binary file added __pycache__/test_system_check.cpython-313.pyc
Binary file not shown.
57 changes: 52 additions & 5 deletions system_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ 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
new_string = ticket_string.split("-")
depature_airport_code = new_string[2]
return depature_airport_code
Comment on lines +22 to +23
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in variable name: "depature" should be "departure".

Suggested change
depature_airport_code = new_string[2]
return depature_airport_code
departure_airport_code = new_string[2]
return departure_airport_code

Copilot uses AI. Check for mistakes.
print(get_departure_airport("FL-JO234-JNB-CPT-2023"))
Copy link

Copilot AI Nov 28, 2025

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 production code. Print statements at the module level can clutter output and are typically only used during development/debugging.

Copilot uses AI. Check for mistakes.



def check_baggage_allowance(ticket_string: str):
"""
Expand All @@ -36,7 +41,17 @@ def check_baggage_allowance(ticket_string: str):
- For any other code: return "Standard - 0kg"
"""
# TODO: Write your code here
pass
new_string = ticket_string.split("-")
baggage_allowance = new_string[0]
if baggage_allowance == 'EC':
return "Economy - 20kg"
if baggage_allowance == 'BS':
return "Business - 40kg"
if baggage_allowance == 'FL':
Comment on lines +48 to +50
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using elif instead of multiple if statements for mutually exclusive conditions. This improves readability and performance by avoiding unnecessary condition checks once a match is found.

For example:

if baggage_allowance == 'EC':
    return "Economy - 20kg"
elif baggage_allowance == 'BS':
    return "Business - 40kg"
elif baggage_allowance == 'FL':
    return "First Class - 60kg"
else:
    return "Standard - 0kg"
Suggested change
if baggage_allowance == 'BS':
return "Business - 40kg"
if baggage_allowance == 'FL':
elif baggage_allowance == 'BS':
return "Business - 40kg"
elif baggage_allowance == 'FL':

Copilot uses AI. Check for mistakes.
return "First Class - 60kg"
else:
return "Standard - 0kg"
print(check_baggage_allowance("FL-JO234-JNB-CPT-2023"))
Copy link

Copilot AI Nov 28, 2025

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 production code. Print statements at the module level can clutter output and are typically only used during development/debugging.

Copilot uses AI. Check for mistakes.

def validate_flight_number(ticket_string: str):
"""
Expand All @@ -50,7 +65,21 @@ def validate_flight_number(ticket_string: str):
- If the numeric part cannot be converted to a number, return "Invalid Flight"
"""
# TODO: Write your code here
pass
new_string = ticket_string.split("-")
flight_number = new_string[1]
# I finally figured it out! is.digit() is a str method, and I was using it after I had converted number_portion into an int. Brain cells restored!
number_portion = str(flight_number.replace("JO", "").replace("A", ""))
if not number_portion.isdigit():
return "Invalid Flight"

number_portion = int(number_portion)

if number_portion % 2 == 0:
return "Valid - Northbound"
if number_portion % 2 != 0:
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using elif instead of separate if statements for the mutually exclusive northbound/southbound conditions. Since a number can't be both even and odd, using elif improves code clarity.

For example:

if number_portion % 2 == 0:
    return "Valid - Northbound"
else:  # or elif number_portion % 2 != 0:
    return "Valid - Southbound"
Suggested change
if number_portion % 2 != 0:
elif number_portion % 2 != 0:

Copilot uses AI. Check for mistakes.
return "Valid - Southbound"
print(validate_flight_number("FL-JOABC-JNB-CPT-2023"))



# ==========================================
Expand All @@ -72,7 +101,15 @@ def is_leap_year(year: int):
Return True or False (Boolean).
"""
# TODO: Write your code here
pass
if year % 400 == 0:
return True
elif year % 100 == 0:
return False
elif year % 4 == 0:
return True
else:
return False
print(is_leap_year(1900))
Copy link

Copilot AI Nov 28, 2025

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 production code. Print statements at the module level can clutter output and are typically only used during development/debugging.

Copilot uses AI. Check for mistakes.


# ==========================================
Expand Down Expand Up @@ -105,4 +142,14 @@ def reactor_status(temp: int, radiation: int):
- For all other cases: return "Normal Operation"
"""
# TODO: Write your code here
pass
if temp in range(1000, 2001) and radiation > 100:
return "WARNING"
if temp < 0 or radiation < 0:
return "Sensor Error"
if temp > 2000 or radiation > 500:
return "CRITICAL"
if temp < 500:
return "Maintenance Mode"
else:
return "Normal Operation"
Comment on lines +145 to +154
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic order is incorrect. The function checks for WARNING conditions before checking for CRITICAL or Sensor Error conditions. This means that values like temp=1500, radiation=600 will incorrectly return "WARNING" instead of "CRITICAL" (since radiation > 500 should trigger CRITICAL).

The checks should be reordered according to the documented priority in the docstring:

  1. Sensor Error (negative checks) - first
  2. CRITICAL checks - second
  3. WARNING checks - third
  4. Maintenance Mode - fourth
  5. Normal Operation - last

Correct order:

if temp < 0 or radiation < 0:
    return "Sensor Error"
if temp > 2000 or radiation > 500:
    return "CRITICAL"
if temp in range(1000, 2001) and radiation > 100:
    return "WARNING"
if temp < 500:
    return "Maintenance Mode"
else:
    return "Normal Operation"

Copilot uses AI. Check for mistakes.
print(reactor_status(1500, 200))
Copy link

Copilot AI Nov 28, 2025

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 production code. Print statements at the module level can clutter output and are typically only used during development/debugging.

Copilot uses AI. Check for mistakes.
19 changes: 19 additions & 0 deletions test_reactor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import unittest
from system_check import reactor_status

class TestReactor:
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TestReactor class must inherit from unittest.TestCase for the test methods to work properly. Without this inheritance, the test runner won't recognize this as a test class, and methods like self.assertEqual will fail since they are not defined.

Change:

class TestReactor:

To:

class TestReactor(unittest.TestCase):
Suggested change
class TestReactor:
class TestReactor(unittest.TestCase):

Copilot uses AI. Check for mistakes.

def test_critical(self):
self.assertEqual(reactor_status(2500, 10), "CRITICAL")
self.assertEqual(reactor_status(500, 600), "CRITICAL")


def test_warning(self):
self.assertEqual(reactor_status(1500, 200), "WARNING")
self.assertEqual(reactor_status(1000, 200), "WARNING")

def test_normal(self):
self.assertEqual(reactor_status(800, 50), "Normal Operation")
Comment on lines +6 to +16
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test coverage for reactor_status is incomplete. According to the logic tree in the function's docstring, the following scenarios are missing tests:

  1. Sensor Error: No test case for negative temperature or radiation (e.g., reactor_status(-1, 50) or reactor_status(500, -10))
  2. Maintenance Mode: No test case for temperature < 500 (e.g., reactor_status(400, 50))

These scenarios are tested in test_system_check.py but should also be included here for comprehensive TDD coverage.

Copilot uses AI. Check for mistakes.

if __name__ == '__main__':
unittest.main()