Esempio n. 1
0
    def test_get_order_when_order_doesnot_exist(self, mock_get):
        '''Test get_order when order doesnot exist.
        '''
        # Arrange
        with self.app.app_context():
            mock_get.return_value = None
            order_controller = OrderController(self.request_context)

            # Act
            result = order_controller.get_order(1)

            # Assert
            assert result.status_code == 400
            assert result.get_json()['msg'] == 'Order not found'
Esempio n. 2
0
    def test_get_order_ok_response(self, mock_get_user_by_email_or_id,
                                   mock_get):
        '''Test get_order OK response.
        '''
        # Arrange
        with self.app.app_context():
            mock_get.return_value = self.mock_order
            mock_get_user_by_email_or_id.return_value = {
                'id': '1',
                'mail': '*****@*****.**',
                'first_name': 'Joseph',
                'last_name': 'Serunjogi'
            }
            order_controller = OrderController(self.request_context)

            # Act
            result = order_controller.get_order(1)

            # Assert
            assert result.status_code == 200
            assert result.get_json()['msg'] == 'OK'