tests/testthat/test_personal_api.R

# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate

context("Test PersonalApi")

api.instance <- PersonalApi$new()

test_that("Country", {
  # tests for Country
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 10 UNITS] Infer the likely country of residence of a personal full name, or one surname. Assumes names as they are in the country of residence OR the country of origin.
  # @param character  personal.name.full   
  # @return [PersonalNameGeoOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("CountryBatch", {
  # tests for CountryBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 10 UNITS] Infer the likely country of residence of up to 1000 personal full names, or surnames. Assumes names as they are in the country of residence OR the country of origin.
  # @param BatchPersonalNameIn  batch.personal.name.in  A list of personal names  (optional)
  # @return [BatchPersonalNameGeoOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("Diaspora", {
  # tests for Diaspora
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 20 UNITS] Infer the likely ethnicity/diaspora of a personal name, given a country of residence ISO2 code (ex. US, CA, AU, NZ etc.)
  # @param character  country.iso2   
  # @param character  first.name   
  # @param character  last.name   
  # @return [FirstLastNameDiasporaedOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("DiasporaBatch", {
  # tests for DiasporaBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 20 UNITS] Infer the likely ethnicity/diaspora of up to 1000 personal names, given a country of residence ISO2 code (ex. US, CA, AU, NZ etc.)
  # @param BatchFirstLastNameGeoIn  batch.first.last.name.geo.in  A list of personal names  (optional)
  # @return [BatchFirstLastNameDiasporaedOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("Gender", {
  # tests for Gender
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of a name.
  # @param character  first.name   
  # @param character  last.name   
  # @return [FirstLastNameGenderedOut]

  api.instance$apiClient$apiKeys['X-API-KEY'] <- Sys.getenv("API_KEY")
  result <- api.instance$Gender("William", "Cheng")

  expect_equal(result$firstName, "William")
  expect_equal(result$lastName, "Cheng")
  expect_equal(result$genderScale, -1)
  expect_equal(result$likelyGender, "male")
  expect_gt(result$score, 6.0)

})

test_that("GenderBatch", {
  # tests for GenderBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of up to 1000 names, detecting automatically the cultural context.
  # @param BatchFirstLastNameIn  batch.first.last.name.in  A list of personal names  (optional)
  # @return [BatchFirstLastNameGenderedOut]

  api.instance$apiClient$apiKeys['X-API-KEY'] <- Sys.getenv("API_KEY")

  result <- api.instance$Gender("William", "Cheng")

  expect_equal(result$firstName, "William")
  expect_equal(result$lastName, "Cheng")
  expect_equal(result$genderScale, -1)
  expect_equal(result$likelyGender, "male")
  expect_gt(result$score, 6.0)
})

test_that("GenderFull", {
  # tests for GenderFull
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of a full name, ex. John H. Smith
  # @param character  full.name   
  # @return [FirstLastNameGenderedOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("GenderFullBatch", {
  # tests for GenderFullBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of up to 1000 full names, detecting automatically the cultural context.
  # @param BatchPersonalNameIn  batch.personal.name.in  A list of personal names  (optional)
  # @return [BatchPersonalNameGenderedOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("GenderFullGeo", {
  # tests for GenderFullGeo
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of a full name, given a local context (ISO2 country code).
  # @param character  full.name   
  # @param character  country.iso2   
  # @return [FirstLastNameGenderedOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("GenderFullGeoBatch", {
  # tests for GenderFullGeoBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of up to 1000 full names, with a given cultural context (country ISO2 code).
  # @param BatchPersonalNameGeoIn  batch.personal.name.geo.in  A list of personal names, with a country ISO2 code  (optional)
  # @return [BatchPersonalNameGenderedOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("GenderGeo", {
  # tests for GenderGeo
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of a name, given a local context (ISO2 country code).
  # @param character  first.name   
  # @param character  last.name   
  # @param character  country.iso2   
  # @return [FirstLastNameGenderedOut]

  api.instance$apiClient$apiKeys['X-API-KEY'] <- Sys.getenv("API_KEY")
  result <- api.instance$GenderGeo("William", "Cheng", "US")

  expect_equal(result$firstName, "William")
  expect_equal(result$lastName, "Cheng")
  expect_equal(result$genderScale, -1)
  expect_equal(result$likelyGender, "male")
  expect_gt(result$score, 6.0)
})

test_that("GenderGeoBatch", {
  # tests for GenderGeoBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of up to 1000 names, each given a local context (ISO2 country code).
  # @param BatchFirstLastNameGeoIn  batch.first.last.name.geo.in  A list of names, with country code.  (optional)
  # @return [BatchFirstLastNameGenderedOut]

  var.batch.first.last.name.geo.in <- BatchFirstLastNameGeoIn$new() # BatchFirstLastNameGeoIn | A list of names, with country code.
  var.batch.first.last.name.geo.in$personalNames <- list(FirstLastNameGeoIn$new("1", "William", "Cheng", "UK" ),
                                                         FirstLastNameGeoIn$new("2", "Elian", "Carsenat", "JP"))
  api.instance <- PersonalApi$new()
  api.instance$apiClient$apiKeys['X-API-KEY'] <- Sys.getenv("API_KEY")
  result <- api.instance$GenderGeoBatch(batch.first.last.name.geo.in=var.batch.first.last.name.geo.in)

  expect_equal(result$personalNames[[1]]$firstName, "William")
  expect_equal(result$personalNames[[1]]$lastName, "Cheng")
  expect_gt(result$personalNames[[1]]$score, 6)
  expect_equal(result$personalNames[[1]]$likelyGender, "male")
  expect_equal(result$personalNames[[1]]$genderScale, -1)

  expect_equal(result$personalNames[[2]]$firstName, "Elian")
  expect_equal(result$personalNames[[2]]$lastName, "Carsenat")
  expect_gt(result$personalNames[[2]]$score, 3.0)
  expect_equal(result$personalNames[[2]]$likelyGender, "male")
  expect_equal(result$personalNames[[2]]$genderScale, -1)

})

test_that("Origin", {
  # tests for Origin
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 10 UNITS] Infer the likely country of origin of a personal name. Assumes names as they are in the country of origin. For US, CA, AU, NZ and other melting-pots : use &#39;diaspora&#39; instead.
  # @param character  first.name   
  # @param character  last.name   
  # @return [FirstLastNameOriginedOut]

  api.instance$apiClient$apiKeys['X-API-KEY'] <- Sys.getenv("API_KEY")
  result <- api.instance$Origin("William", "Cheng")

  expect_equal(result$firstName, "William")
  expect_equal(result$lastName, "Cheng")
  expect_gt(result$score, 3.0)
  expect_equal(result$countryOrigin, "TW")
  expect_equal(result$countryOriginAlt, "CN")
  expect_equal(result$regionOrigin, "Asia")
  expect_equal(result$topRegionOrigin, "Asia")
  expect_equal(result$subRegionOrigin, "Eastern Asia")
})

test_that("OriginBatch", {
  # tests for OriginBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 10 UNITS] Infer the likely country of origin of up to 1000 names, detecting automatically the cultural context.
  # @param BatchFirstLastNameIn  batch.first.last.name.in  A list of personal names  (optional)
  # @return [BatchFirstLastNameOriginedOut]

  var.batch.first.last.name.in <- BatchFirstLastNameIn$new() # BatchFirstLastNameIn | A list of personal names
  var.batch.first.last.name.in$personalNames <- list(FirstLastNameIn$new("1", "William", "Cheng"),
                                                         FirstLastNameIn$new("2", "Elian", "Carsenat"))
  api.instance <- PersonalApi$new()
  api.instance$apiClient$apiKeys['X-API-KEY'] <- Sys.getenv("API_KEY")
  result <- api.instance$GenderBatch(batch.first.last.name.in=var.batch.first.last.name.in)

  expect_equal(result$personalNames[[1]]$firstName, "William")
  expect_equal(result$personalNames[[1]]$lastName, "Cheng")
  expect_gt(result$personalNames[[1]]$score, 6)
  expect_equal(result$personalNames[[1]]$likelyGender, "male")
  expect_equal(result$personalNames[[1]]$genderScale, -1)

  expect_equal(result$personalNames[[2]]$firstName, "Elian")
  expect_equal(result$personalNames[[2]]$lastName, "Carsenat")
  expect_gt(result$personalNames[[2]]$score, 3.0)
  expect_equal(result$personalNames[[2]]$likelyGender, "male")
  expect_equal(result$personalNames[[2]]$genderScale, -1)
})

test_that("ParsedGenderBatch", {
  # tests for ParsedGenderBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of up to 1000 fully parsed names, detecting automatically the cultural context.
  # @param BatchParsedFullNameIn  batch.parsed.full.name.in  A list of personal names  (optional)
  # @return [BatchFirstLastNameGenderedOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("ParsedGenderGeoBatch", {
  # tests for ParsedGenderGeoBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # Infer the likely gender of up to 1000 fully parsed names, detecting automatically the cultural context.
  # @param BatchParsedFullNameGeoIn  batch.parsed.full.name.geo.in  A list of personal names  (optional)
  # @return [BatchFirstLastNameGenderedOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("UsRaceEthnicity", {
  # tests for UsRaceEthnicity
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 10 UNITS] Infer a US resident&#39;s likely race/ethnicity according to US Census taxonomy.
  # @param character  first.name   
  # @param character  last.name   
  # @return [FirstLastNameUSRaceEthnicityOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("UsRaceEthnicityBatch", {
  # tests for UsRaceEthnicityBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 10 UNITS] Infer up-to 1000 US resident&#39;s likely race/ethnicity according to US Census taxonomy.
  # @param BatchFirstLastNameGeoIn  batch.first.last.name.geo.in  A list of personal names  (optional)
  # @return [BatchFirstLastNameUSRaceEthnicityOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("UsRaceEthnicityZIP5", {
  # tests for UsRaceEthnicityZIP5
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 10 UNITS] Infer a US resident&#39;s likely race/ethnicity according to US Census taxonomy, using (optional) ZIP5 code info.
  # @param character  first.name   
  # @param character  last.name   
  # @param character  zip5.code   
  # @return [FirstLastNameUSRaceEthnicityOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})

test_that("UsZipRaceEthnicityBatch", {
  # tests for UsZipRaceEthnicityBatch
  # base path: https://v2.namsor.com/NamSorAPIv2
  # [USES 10 UNITS] Infer up-to 1000 US resident&#39;s likely race/ethnicity according to US Census taxonomy, with (optional) ZIP code.
  # @param BatchFirstLastNameGeoZippedIn  batch.first.last.name.geo.zipped.in  A list of personal names  (optional)
  # @return [BatchFirstLastNameUSRaceEthnicityOut]

  # uncomment below to test the operation
  #expect_equal(result, "EXPECTED_RESULT")
})
wing328/namsor-r-client documentation built on May 26, 2019, 7:01 p.m.