When(/^the client requests the status of an? (non-existent|empty) filename$/) do |filename_status|
  case filename_status
  when "non-existent"
    @res = retrieve_asset_status(filename: "nonexistent_000")
  when "empty"
    @res = retrieve_asset_status(filename: nil)
  end
end

Then(/^an (\d+) error should be obtained$/) do |error|
  parsed_response = JSON.parse(@res[:response])

  case error.to_i
  when 404
    assert_equal(404, @res[:code])
    assert_equal("Asset not found", parsed_response["message"])
    assert_equal("not_found_error", parsed_response["code"])
  when 400
    assert_equal(400, @res[:code])
    assert_equal("Invalid filename value.", parsed_response["message"])
    assert_equal("error_query_validation", parsed_response["code"])
  when 500
    # not sure how to simulate this yet
  end
end

And(/^\/GET asset response is \[(finished|not_found)\]$/) do |asset_status|
  case asset_status
  when "finished"
    @res = wait_asset_status_finished(@filename, 50)
    parsed_response = JSON.parse(@res[:response])

    assert_equal(200, @res[:code])
    assert_equal("finished", parsed_response["status"])
  when "not_found"
    @res = retrieve_asset_status(filename: @filename)
    parsed_response = JSON.parse(@res[:response])

    assert_equal(404, @res[:code])
    assert_equal("not_found_error", parsed_response["code"])
  end
end
