def test_mission_arrive_at_station(self): # arrange expected = [{ 'id': 'm01', 'rocketId': 'falcon1', 'daysToArriveAtStation': 10, 'status': "ON_STATION" }, { 'id': 'm02', 'rocketId': 'falcon1', 'daysToArriveAtStation': 30, 'status': "ON_HOLD" }, { 'id': 'm03', 'rocketId': 'falcon9', 'daysToArriveAtStation': 60, 'status': "ON_ROUTE" }] # act dummy_data.add_dummy_data() app.assign_requests_missions() app.simulate_by_days(15) # assert self.assertListEqual( app.get_missions(), expected, "The mission m01 has changed its status flag" "to on station")
def test_assignments_requests(self): # arrange expected = [{ 'id': 'p04', 'description': 'spare parts', 'weight': 20.2, 'daysMaxToDeliver': 3, 'status': 'IMPOSSIBLE_TO_FULFILL' }, { 'id': 'p01', 'description': 'oxygen', 'weight': 105.7, 'daysMaxToDeliver': 28, 'status': 'ALLOCATED' }, { 'id': 'p02', 'description': 'food', 'weight': 300.0, 'daysMaxToDeliver': 28, 'status': 'ALLOCATED' }, { 'id': 'p03', 'description': 'spare parts', 'weight': 800.0, 'daysMaxToDeliver': 60, 'status': 'ALLOCATED' }] # act dummy_data.add_dummy_data() app.assign_requests_missions() # assert self.assertListEqual(app.get_requests(), expected, "The requests status must be updated")
def test_assignments_missions(self): # arrange expected = [{ 'id': 'm01', 'rocketId': 'falcon1', 'daysToArriveAtStation': 10, 'status': "ON_ROUTE" }, { 'id': 'm02', 'rocketId': 'falcon1', 'daysToArriveAtStation': 30, 'status': "ON_HOLD" }, { 'id': 'm03', 'rocketId': 'falcon9', 'daysToArriveAtStation': 60, 'status': "ON_ROUTE" }] # act dummy_data.add_dummy_data() app.assign_requests_missions() # assert self.assertListEqual(app.get_missions(), expected, "The missions status must be updated")
def test_assignment_arrive_at_station(self): # arrange expected = [{ 'missionId': 'm03', 'daysToArriveAtStation': 45, 'payload': 22000, 'requestIds': ['p03'] }] # act dummy_data.add_dummy_data() app.assign_requests_missions() app.simulate_by_days(15) # assert self.assertListEqual( app.get_assignments(), expected, "The mission m01 was removed from the assignment list")
def test_rocket_arrive_at_station(self): # arrange expected = [{ 'id': 'falcon1', 'payload': 600, 'success': True }, { 'id': 'falcon9', 'payload': 22800, 'success': False }] # act dummy_data.add_dummy_data() app.assign_requests_missions() app.simulate_by_days(15) # assert self.assertListEqual( app.get_rockets(), expected, "The rocket falcon1 has changed its success flag")
def test_assignments(self): # arrange expected = [{ 'missionId': 'm01', 'daysToArriveAtStation': 10, 'payload': 194.3, 'requestIds': ['p01', 'p02'] }, { 'missionId': 'm03', 'daysToArriveAtStation': 60, 'payload': 22000.0, 'requestIds': ['p03'] }] # act dummy_data.add_dummy_data() app.assign_requests_missions() # assert self.assertListEqual(app.get_assignments(), expected, "Must apply the assignments properly")
def test_requests_arrive_at_station(self): # arrange expected = [{ 'id': 'p04', 'description': 'spare parts', 'weight': 20.2, 'daysMaxToDeliver': 3, 'status': 'IMPOSSIBLE_TO_FULFILL' }, { 'id': 'p01', 'description': 'oxygen', 'weight': 105.7, 'daysMaxToDeliver': 28, 'status': 'DELIVERED' }, { 'id': 'p02', 'description': 'food', 'weight': 300.0, 'daysMaxToDeliver': 28, 'status': 'DELIVERED' }, { 'id': 'p03', 'description': 'spare parts', 'weight': 800.0, 'daysMaxToDeliver': 60, 'status': 'ALLOCATED' }] # act dummy_data.add_dummy_data() app.assign_requests_missions() app.simulate_by_days(15) # assert self.assertListEqual( app.get_requests(), expected, "The requests p01 and p02 have changed the status " "to delivered")
def test_simulate_by_5_days(self): # arrange expected = [{ 'missionId': 'm01', 'daysToArriveAtStation': 5, 'payload': 194.3, 'requestIds': ['p01', 'p02'] }, { 'missionId': 'm03', 'daysToArriveAtStation': 55, 'payload': 22000, 'requestIds': ['p03'] }] # act dummy_data.add_dummy_data() app.assign_requests_missions() app.simulate_by_days(5) # assert self.assertListEqual( app.get_assignments(), expected, "The time to arrive at the station must be 5 days less")
def menu_assign_requests_missions() -> None: from app import assign_requests_missions, validate_assignment_process exists_enough_data = validate_assignment_process() if exists_enough_data: print_header("Assignments") try: message = assign_requests_missions() print_success(message) except ValueError as error: print_error(str(error)) else: print_error("Should exist at least one rocket," " one request, and one mission for init" " the assignment process")
def test_not_exists_enough_data_for_assignment_process(self): # assert with self.assertRaises(ValueError): app.assign_requests_missions()