From b6314c8927a8411561577c0dfd100018947de42e Mon Sep 17 00:00:00 2001 From: LiNk-NY Date: Tue, 12 May 2020 18:11:26 -0400 Subject: [PATCH] update tests based on generator --- .../petstore/R/tests/testthat/test_order.R | 12 ++-- .../petstore/R/tests/testthat/test_pet.R | 8 +-- .../petstore/R/tests/testthat/test_pet_api.R | 46 ++++++------- .../petstore/R/tests/testthat/test_petstore.R | 68 ------------------- .../R/tests/testthat/test_store_api.R | 16 ++--- .../petstore/R/tests/testthat/test_user.R | 18 ++--- .../petstore/R/tests/testthat/test_user_api.R | 34 +++++----- 7 files changed, 67 insertions(+), 135 deletions(-) delete mode 100644 samples/client/petstore/R/tests/testthat/test_petstore.R diff --git a/samples/client/petstore/R/tests/testthat/test_order.R b/samples/client/petstore/R/tests/testthat/test_order.R index 5fb144f9372b..33b87520254d 100644 --- a/samples/client/petstore/R/tests/testthat/test_order.R +++ b/samples/client/petstore/R/tests/testthat/test_order.R @@ -12,11 +12,11 @@ test_that("id", { #expect_equal(model.instance$`id`, "EXPECTED_RESULT") }) -test_that("pet_id", { - # tests for the property `pet_id` (integer) +test_that("petId", { + # tests for the property `petId` (integer) # uncomment below to test the property - #expect_equal(model.instance$`pet_id`, "EXPECTED_RESULT") + #expect_equal(model.instance$`petId`, "EXPECTED_RESULT") }) test_that("quantity", { @@ -26,11 +26,11 @@ test_that("quantity", { #expect_equal(model.instance$`quantity`, "EXPECTED_RESULT") }) -test_that("ship_date", { - # tests for the property `ship_date` (character) +test_that("shipDate", { + # tests for the property `shipDate` (character) # uncomment below to test the property - #expect_equal(model.instance$`ship_date`, "EXPECTED_RESULT") + #expect_equal(model.instance$`shipDate`, "EXPECTED_RESULT") }) test_that("status", { diff --git a/samples/client/petstore/R/tests/testthat/test_pet.R b/samples/client/petstore/R/tests/testthat/test_pet.R index 8d3ce54a55d1..ac3e4f31dd10 100644 --- a/samples/client/petstore/R/tests/testthat/test_pet.R +++ b/samples/client/petstore/R/tests/testthat/test_pet.R @@ -26,15 +26,15 @@ test_that("name", { #expect_equal(model.instance$`name`, "EXPECTED_RESULT") }) -test_that("photo_urls", { - # tests for the property `photo_urls` (character) +test_that("photoUrls", { + # tests for the property `photoUrls` (array[character]) # uncomment below to test the property - #expect_equal(model.instance$`photo_urls`, "EXPECTED_RESULT") + #expect_equal(model.instance$`photoUrls`, "EXPECTED_RESULT") }) test_that("tags", { - # tests for the property `tags` (Tag) + # tests for the property `tags` (array[Tag]) # uncomment below to test the property #expect_equal(model.instance$`tags`, "EXPECTED_RESULT") diff --git a/samples/client/petstore/R/tests/testthat/test_pet_api.R b/samples/client/petstore/R/tests/testthat/test_pet_api.R index 021f6228af90..3388d2d63ed7 100644 --- a/samples/client/petstore/R/tests/testthat/test_pet_api.R +++ b/samples/client/petstore/R/tests/testthat/test_pet_api.R @@ -7,9 +7,9 @@ api.instance <- PetApi$new() test_that("AddPet", { # tests for AddPet + # base path: http://petstore.swagger.io/v2 # Add a new pet to the store - # @param body Pet object that needs to be added to the store - # @param [Hash] opts the optional parameters + # @param Pet body Pet object that needs to be added to the store # @return [Void] # uncomment below to test the operation @@ -18,10 +18,10 @@ test_that("AddPet", { test_that("DeletePet", { # tests for DeletePet + # base path: http://petstore.swagger.io/v2 # Deletes a pet - # @param pet.id Pet id to delete - # @param [Hash] opts the optional parameters - # @option opts [character] :api.key + # @param integer pet.id Pet id to delete + # @param character api.key (optional) # @return [Void] # uncomment below to test the operation @@ -30,11 +30,11 @@ test_that("DeletePet", { test_that("FindPetsByStatus", { # tests for FindPetsByStatus + # base path: http://petstore.swagger.io/v2 # Finds Pets by status # Multiple status values can be provided with comma separated strings - # @param status Status values that need to be considered for filter - # @param [Hash] opts the optional parameters - # @return [Pet] + # @param array[character] status Status values that need to be considered for filter + # @return [array[Pet]] # uncomment below to test the operation #expect_equal(result, "EXPECTED_RESULT") @@ -42,11 +42,11 @@ test_that("FindPetsByStatus", { test_that("FindPetsByTags", { # tests for FindPetsByTags + # base path: http://petstore.swagger.io/v2 # Finds Pets by tags # Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - # @param tags Tags to filter by - # @param [Hash] opts the optional parameters - # @return [Pet] + # @param array[character] tags Tags to filter by + # @return [array[Pet]] # uncomment below to test the operation #expect_equal(result, "EXPECTED_RESULT") @@ -54,10 +54,10 @@ test_that("FindPetsByTags", { test_that("GetPetById", { # tests for GetPetById + # base path: http://petstore.swagger.io/v2 # Find pet by ID # Returns a single pet - # @param pet.id ID of pet to return - # @param [Hash] opts the optional parameters + # @param integer pet.id ID of pet to return # @return [Pet] # uncomment below to test the operation @@ -66,9 +66,9 @@ test_that("GetPetById", { test_that("UpdatePet", { # tests for UpdatePet + # base path: http://petstore.swagger.io/v2 # Update an existing pet - # @param body Pet object that needs to be added to the store - # @param [Hash] opts the optional parameters + # @param Pet body Pet object that needs to be added to the store # @return [Void] # uncomment below to test the operation @@ -77,11 +77,11 @@ test_that("UpdatePet", { test_that("UpdatePetWithForm", { # tests for UpdatePetWithForm + # base path: http://petstore.swagger.io/v2 # Updates a pet in the store with form data - # @param pet.id ID of pet that needs to be updated - # @param [Hash] opts the optional parameters - # @option opts [character] :name Updated name of the pet - # @option opts [character] :status Updated status of the pet + # @param integer pet.id ID of pet that needs to be updated + # @param character name Updated name of the pet (optional) + # @param character status Updated status of the pet (optional) # @return [Void] # uncomment below to test the operation @@ -90,11 +90,11 @@ test_that("UpdatePetWithForm", { test_that("UploadFile", { # tests for UploadFile + # base path: http://petstore.swagger.io/v2 # uploads an image - # @param pet.id ID of pet to update - # @param [Hash] opts the optional parameters - # @option opts [character] :additional.metadata Additional data to pass to server - # @option opts [data.frame] :file file to upload + # @param integer pet.id ID of pet to update + # @param character additional.metadata Additional data to pass to server (optional) + # @param data.frame file file to upload (optional) # @return [ModelApiResponse] # uncomment below to test the operation diff --git a/samples/client/petstore/R/tests/testthat/test_petstore.R b/samples/client/petstore/R/tests/testthat/test_petstore.R deleted file mode 100644 index 2e24b32f1241..000000000000 --- a/samples/client/petstore/R/tests/testthat/test_petstore.R +++ /dev/null @@ -1,68 +0,0 @@ -context("basic functionality") -petApi <- PetApi$new() -petId <- 123321 -test_that("AddPet", { - pet <- Pet$new("name_test", list("photo_test", "second test"), - petId, Category$new(id=450, name="test_cat"), - list(Tag$new(id=123, name="tag_test"), Tag$new(id=456, name="unknown")), - "available") - #pet <- Pet$new("name_test", - # list("photo_test", "second test"), - # category=Category$new(id=450, name="test_cat"), - # id=petId, - # tags=list(Tag$new(id=123, name="tag_test"), Tag$new(id=456, name="unknown")), - # status="available") - result <-petApi$AddPet(pet) - expect_equal(petId, 123321) - expect_equal(result, NULL) -}) - -test_that("Test Pet", { - pet <- Pet$new("name_test", list("photo_test", "second test"), - petId, Category$new(id=450, name="test_cat"), - list(Tag$new(id=123, name="tag_test"), Tag$new(id=456, name="unknown")), - "available") - - pet2 <- Pet$new() - #pet2$fromJSON(jsonlite::toJSON(pet$toJSON(), auto_unbox=TRUE)) - #expect_equal(pet, pet2) -}) - -test_that("Test Category", { - c1 <- Category$new(id=450, name="test_cat") - c2 <- Category$new() - c2$fromJSON(jsonlite::toJSON(c1$toJSON(), auto_unbox=TRUE)) - expect_equal(c1, c2) -}) - -test_that("GetPetById", { - response <- petApi$GetPetById(petId) - expect_equal(response$id, petId) - expect_equal(response$name, "name_test") - #expect_equal(response$category, Category$new(id=450, name="test_cat")) - expect_equal(response$photoUrls, list("photo_test", "second test")) - expect_equal(response$status, "available") - expect_equal(response$tags, list(Tag$new(id=123, name="tag_test"), Tag$new(id=456, name="unknown"))) -}) - -#test_that("GetPetById", { -# pet.id <- pet.id -# pet <- Pet$new(pet.id, NULL, "name_test2", -# list("photo_test2", "second test2"), -# NULL, NULL) -# result <-petApi$AddPet(pet) -# -# response <- petApi$GetPetById(pet.id) -# -# expect_equal(response$id, pet.id) -# expect_equal(response$name, "name_test2") -# #expect_equal(response$category, Category$new(450,"test_cat")) -# expect_equal(response$photoUrls, list("photo_test2", "second test2")) -# expect_equal(response$status, NULL) -# #expect_equal(response$tags, list(Tag$new(123, "tag_test"), Tag$new(456, "unknown"))) -#}) - -#test_that("updatePetWithForm", { -# response <- petApi$updatePetWithForm(petId, "test", "sold") -# expect_equal(response, "Pet updated") -#}) diff --git a/samples/client/petstore/R/tests/testthat/test_store_api.R b/samples/client/petstore/R/tests/testthat/test_store_api.R index e1290358b43f..1fe2e9eaaa86 100644 --- a/samples/client/petstore/R/tests/testthat/test_store_api.R +++ b/samples/client/petstore/R/tests/testthat/test_store_api.R @@ -7,10 +7,10 @@ api.instance <- StoreApi$new() test_that("DeleteOrder", { # tests for DeleteOrder + # base path: http://petstore.swagger.io/v2 # Delete purchase order by ID # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - # @param order.id ID of the order that needs to be deleted - # @param [Hash] opts the optional parameters + # @param character order.id ID of the order that needs to be deleted # @return [Void] # uncomment below to test the operation @@ -19,10 +19,10 @@ test_that("DeleteOrder", { test_that("GetInventory", { # tests for GetInventory + # base path: http://petstore.swagger.io/v2 # Returns pet inventories by status # Returns a map of status codes to quantities - # @param [Hash] opts the optional parameters - # @return [integer] + # @return [map(integer)] # uncomment below to test the operation #expect_equal(result, "EXPECTED_RESULT") @@ -30,10 +30,10 @@ test_that("GetInventory", { test_that("GetOrderById", { # tests for GetOrderById + # base path: http://petstore.swagger.io/v2 # Find purchase order by ID # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - # @param order.id ID of pet that needs to be fetched - # @param [Hash] opts the optional parameters + # @param integer order.id ID of pet that needs to be fetched # @return [Order] # uncomment below to test the operation @@ -42,9 +42,9 @@ test_that("GetOrderById", { test_that("PlaceOrder", { # tests for PlaceOrder + # base path: http://petstore.swagger.io/v2 # Place an order for a pet - # @param body order placed for purchasing the pet - # @param [Hash] opts the optional parameters + # @param Order body order placed for purchasing the pet # @return [Order] # uncomment below to test the operation diff --git a/samples/client/petstore/R/tests/testthat/test_user.R b/samples/client/petstore/R/tests/testthat/test_user.R index 401196a90d76..9929623b42f8 100644 --- a/samples/client/petstore/R/tests/testthat/test_user.R +++ b/samples/client/petstore/R/tests/testthat/test_user.R @@ -19,18 +19,18 @@ test_that("username", { #expect_equal(model.instance$`username`, "EXPECTED_RESULT") }) -test_that("first_name", { - # tests for the property `first_name` (character) +test_that("firstName", { + # tests for the property `firstName` (character) # uncomment below to test the property - #expect_equal(model.instance$`first_name`, "EXPECTED_RESULT") + #expect_equal(model.instance$`firstName`, "EXPECTED_RESULT") }) -test_that("last_name", { - # tests for the property `last_name` (character) +test_that("lastName", { + # tests for the property `lastName` (character) # uncomment below to test the property - #expect_equal(model.instance$`last_name`, "EXPECTED_RESULT") + #expect_equal(model.instance$`lastName`, "EXPECTED_RESULT") }) test_that("email", { @@ -54,11 +54,11 @@ test_that("phone", { #expect_equal(model.instance$`phone`, "EXPECTED_RESULT") }) -test_that("user_status", { - # tests for the property `user_status` (integer) +test_that("userStatus", { + # tests for the property `userStatus` (integer) # User Status # uncomment below to test the property - #expect_equal(model.instance$`user_status`, "EXPECTED_RESULT") + #expect_equal(model.instance$`userStatus`, "EXPECTED_RESULT") }) diff --git a/samples/client/petstore/R/tests/testthat/test_user_api.R b/samples/client/petstore/R/tests/testthat/test_user_api.R index 283c7c7e964f..8e1a0f6d4850 100644 --- a/samples/client/petstore/R/tests/testthat/test_user_api.R +++ b/samples/client/petstore/R/tests/testthat/test_user_api.R @@ -7,10 +7,10 @@ api.instance <- UserApi$new() test_that("CreateUser", { # tests for CreateUser + # base path: http://petstore.swagger.io/v2 # Create user # This can only be done by the logged in user. - # @param body Created user object - # @param [Hash] opts the optional parameters + # @param User body Created user object # @return [Void] # uncomment below to test the operation @@ -19,9 +19,9 @@ test_that("CreateUser", { test_that("CreateUsersWithArrayInput", { # tests for CreateUsersWithArrayInput + # base path: http://petstore.swagger.io/v2 # Creates list of users with given input array - # @param body List of user object - # @param [Hash] opts the optional parameters + # @param array[User] body List of user object # @return [Void] # uncomment below to test the operation @@ -30,9 +30,9 @@ test_that("CreateUsersWithArrayInput", { test_that("CreateUsersWithListInput", { # tests for CreateUsersWithListInput + # base path: http://petstore.swagger.io/v2 # Creates list of users with given input array - # @param body List of user object - # @param [Hash] opts the optional parameters + # @param array[User] body List of user object # @return [Void] # uncomment below to test the operation @@ -41,10 +41,10 @@ test_that("CreateUsersWithListInput", { test_that("DeleteUser", { # tests for DeleteUser + # base path: http://petstore.swagger.io/v2 # Delete user # This can only be done by the logged in user. - # @param username The name that needs to be deleted - # @param [Hash] opts the optional parameters + # @param character username The name that needs to be deleted # @return [Void] # uncomment below to test the operation @@ -53,9 +53,9 @@ test_that("DeleteUser", { test_that("GetUserByName", { # tests for GetUserByName + # base path: http://petstore.swagger.io/v2 # Get user by user name - # @param username The name that needs to be fetched. Use user1 for testing. - # @param [Hash] opts the optional parameters + # @param character username The name that needs to be fetched. Use user1 for testing. # @return [User] # uncomment below to test the operation @@ -64,10 +64,10 @@ test_that("GetUserByName", { test_that("LoginUser", { # tests for LoginUser + # base path: http://petstore.swagger.io/v2 # Logs user into the system - # @param username The user name for login - # @param password The password for login in clear text - # @param [Hash] opts the optional parameters + # @param character username The user name for login + # @param character password The password for login in clear text # @return [character] # uncomment below to test the operation @@ -76,8 +76,8 @@ test_that("LoginUser", { test_that("LogoutUser", { # tests for LogoutUser + # base path: http://petstore.swagger.io/v2 # Logs out current logged in user session - # @param [Hash] opts the optional parameters # @return [Void] # uncomment below to test the operation @@ -86,11 +86,11 @@ test_that("LogoutUser", { test_that("UpdateUser", { # tests for UpdateUser + # base path: http://petstore.swagger.io/v2 # Updated user # This can only be done by the logged in user. - # @param username name that need to be deleted - # @param body Updated user object - # @param [Hash] opts the optional parameters + # @param character username name that need to be deleted + # @param User body Updated user object # @return [Void] # uncomment below to test the operation