Exemple #1
0
def test_rack_scan_endpoint_invalid(app):
    """Test getting a invalid rack scan response.

    There is no plugin backend, so the scan will be empty. When
    the scan is empty, we can't filter on racks/boards.
    """
    _, response = app.test_client.get(invalid_rack_scan_url)
    utils.test_error_json(response, errors.FAILED_SCAN_COMMAND)
Exemple #2
0
def test_board_info_endpoint_invalid(app):
    """Issue a request for a nonexistent rack/board.

    While both board and rack do not exist, we get the RACK_NOT_FOUND
    error because of the lookup order.
    """
    _, response = app.test_client.get(invalid_board_info_url)
    utils.test_error_json(response, errors.RACK_NOT_FOUND, 404)
Exemple #3
0
def test_read_endpoint_invalid(app):
    """Test getting a invalid read response.

    We get a DEVICE_NOT_FOUND error because the rack, board, and
    device are used to make a composite ID for the device. If any
    one component is wrong, the ID composite device ID is wrong.
    """
    _, response = app.test_client.get(invalid_read_url)
    utils.test_error_json(response, errors.DEVICE_NOT_FOUND, 404)
def test_write_invalid_endpoint_invalid_data(app):
    """Test posting a invalid write response with invalid POST data.

    Details:
        In this case, rack, board, device are invalid.
        With the invalid POST data, no key is existed,
        the returned error should be INVALID_ARGUMENTS
    """
    invalid_post_data = {
        'empty': {},
        'incorrect_key': {
            'incorrect_key': 'valid'
        }
    }

    for option, payload in invalid_post_data.items():
        _, response = app.test_client.post(invalid_write_url,
                                           data=ujson.dumps(payload))
        utils.test_error_json(response, errors.INVALID_ARGUMENTS, 400)
def test_write_invalid_endpoint_valid_data(app):
    """Test posting a invalid write request with valid POST data.

    Details:
        In this case, rack, board, device are invalid.
        With the valid POST data, keys are corrects and values are valid,
        the returned error should be DEVICE_NOT_FOUND.

        The reason we assume that values are valid is because,
        not like end-to-end test when we have emulator plugin enabled,
        no test data is available for integration test.
        Therefore, there is no real device's value that we can count on.
    """
    valid_post_data = {
        'correct_keys': {
            'action': 'valid',
            'raw': 'valid'
        },
        'incorrect_action': {
            'incorrect_action': 'valid',
            'raw': 'valid'
        },
        'incorrect_raw': {
            'action': 'valid',
            'incorrect_raw': 'valid'
        },
        'absence_action': {
            'raw': 'valid'
        },
        'absence_raw': {
            'action': 'valid'
        }
    }

    for option, payload in valid_post_data.items():
        _, response = app.test_client.post(invalid_write_url,
                                           data=ujson.dumps(payload))
        utils.test_error_json(response, errors.DEVICE_NOT_FOUND, 404)
Exemple #6
0
def test_lock_endpoint_invalid(app):
    """Get lock info for a nonexistent device."""
    _, response = app.test_client.get(invalid_lock_route_url)
    utils.test_error_json(response, errors.DEVICE_NOT_FOUND, 404)
def test_transaction_endpoint_invalid(app):
    """Test getting a invalid transaction response."""
    _, response = app.test_client.get(invalid_transaction_url)
    utils.test_error_json(response, errors.TRANSACTION_NOT_FOUND, 404)
Exemple #8
0
def test_rack_info_endpoint_invalid(app):
    """Issue a request for a nonexistent rack."""
    _, response = app.test_client.get(invalid_rack_info_url)
    utils.test_error_json(response, errors.RACK_NOT_FOUND, 404)