Exemple #1
0
    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")
Exemple #2
0
    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")
Exemple #3
0
    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")
Exemple #4
0
def check_dummy_data() -> None:
    """
    In order to test the assignments and the simulation by days
    without entering manually the required data
    """
    from tests.dummy_data import add_dummy_data

    if len(sys.argv) > 1 and sys.argv[1] == 'dummy-data':
        add_dummy_data()
Exemple #5
0
    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")
Exemple #6
0
    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")
Exemple #7
0
    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")
Exemple #8
0
    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")
Exemple #9
0
    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")