|
| 1 | +require_relative '../../lib/AccountUser/accountUser.rb' |
| 2 | +require_relative '../Helpers/test_helper.rb' |
| 3 | +require 'test/unit' |
| 4 | + |
| 5 | +class AccountUserTest < Test::Unit::TestCase |
| 6 | + def test_AccountUser_create_user_auth |
| 7 | + params = {"url_api" => 'http://api.test.sw.com.mx', "url" => 'http://services.test.sw.com.mx', "user" => ENV["SDKTEST_USER"], "password" => ENV["SDKTEST_PASSWORD"]} |
| 8 | + AccountUser::set(params) |
| 9 | + name = "Prueba UT Hijo Ruby" |
| 10 | + taxId = "XAXX010101000" |
| 11 | + email = "userRuby_#{ENV['SDKTEST_USER']}" |
| 12 | + password = "_#{ENV['SDKTEST_PASSWORD']}" |
| 13 | + notificationEmail = "user_#{ENV['SDKTEST_USER']}" |
| 14 | + phone = "0000000000" |
| 15 | + response = AccountUser::create_user(name,taxId,email,1,false,password,notificationEmail,phone) |
| 16 | + message_expect = "El email '#{email}' ya esta en uso." |
| 17 | + assert(response.get_status == "success" || response.get_message == message_expect) |
| 18 | + end |
| 19 | + |
| 20 | + def test_AccountUser_create_user |
| 21 | + params = {"url_api" => 'http://api.test.sw.com.mx', "token" => ENV["SDKTEST_TOKEN"]} |
| 22 | + AccountUser::set(params) |
| 23 | + name = "Prueba UT Hijo Ruby" |
| 24 | + taxId = "XAXX010101000" |
| 25 | + email = "userRuby_#{ENV['SDKTEST_USER']}" |
| 26 | + password = "_#{ENV['SDKTEST_PASSWORD']}" |
| 27 | + notificationEmail = "user_#{ENV['SDKTEST_USER']}" |
| 28 | + phone = "0000000000" |
| 29 | + response = AccountUser::create_user(name,taxId,email,1,false,password,notificationEmail,phone) |
| 30 | + message_expect = "El email '#{email}' ya esta en uso." |
| 31 | + assert(response.get_status == "success" || response.get_message == message_expect) |
| 32 | + end |
| 33 | + |
| 34 | + #UT de Consulta Usuarios |
| 35 | + def test_AccountUser_All_auth |
| 36 | + params = {"url_api" => 'http://api.test.sw.com.mx', "url" => 'http://services.test.sw.com.mx', "user" => ENV["SDKTEST_USER"], "password" => ENV["SDKTEST_PASSWORD"]} |
| 37 | + AccountUser::set(params) |
| 38 | + response = AccountUser::getUser_all |
| 39 | + assert(response.get_status == "success") |
| 40 | + assert(response.get_data != "") |
| 41 | + end |
| 42 | + |
| 43 | + def test_AccountUser_by_id |
| 44 | + params = {"url_api" => 'http://api.test.sw.com.mx', "token" => ENV["SDKTEST_TOKEN"]} |
| 45 | + AccountUser::set(params) |
| 46 | + idUser = "32501CF2-DC62-4370-B47D-25024C44E131" |
| 47 | + response = AccountUser::getUser_by_IdUser(idUser) |
| 48 | + assert(response.get_status == "success") |
| 49 | + assert(response.get_data != "") |
| 50 | + data = response.get_data |
| 51 | + data.items.each do |user| |
| 52 | + puts "ID: #{user.idUser}, Nombre: #{user.name}, RFC: #{user.taxId}, Email: #{user.email}, Stamps: #{user.stamps}, token: #{user.accessToken}" |
| 53 | + end |
| 54 | + end |
| 55 | + |
| 56 | + def test_AccountUser_by_email |
| 57 | + params = {"url_api" => 'http://api.test.sw.com.mx', "token" => ENV["SDKTEST_TOKEN"]} |
| 58 | + AccountUser::set(params) |
| 59 | + email = "userRuby_#{ENV['SDKTEST_USER']}" |
| 60 | + response = AccountUser::getUser_by_email(email) |
| 61 | + assert(response.get_status == "success") |
| 62 | + assert(response.get_data != "") |
| 63 | + end |
| 64 | + |
| 65 | + def test_AccountUser_by_taxId |
| 66 | + params = {"url_api" => 'http://api.test.sw.com.mx', "token" => ENV["SDKTEST_TOKEN"]} |
| 67 | + AccountUser::set(params) |
| 68 | + taxId = "AAAA000101010" |
| 69 | + response = AccountUser::getUser_by_taxId(taxId) |
| 70 | + assert(response.get_status == "success") |
| 71 | + assert(response.get_data != "") |
| 72 | + end |
| 73 | + |
| 74 | + def test_AccountUser_by_isActive |
| 75 | + params = {"url_api" => 'http://api.test.sw.com.mx', "token" => ENV["SDKTEST_TOKEN"]} |
| 76 | + AccountUser::set(params) |
| 77 | + response = AccountUser::getUser_by_isActive(true) |
| 78 | + assert(response.get_status == "success") |
| 79 | + assert(response.get_data != "") |
| 80 | + end |
| 81 | + |
| 82 | + def test_AccountUser_delete_user |
| 83 | + params = {"url_api" => 'http://api.test.sw.com.mx', "token" => ENV["SDKTEST_TOKEN"]} |
| 84 | + AccountUser::set(params) |
| 85 | + idUser = '2990D2BB-B26A-4FD5-B1CC-07AE84AE8085' |
| 86 | + message_expect = 'El usuario ya ha sido previamente removido' |
| 87 | + response = AccountUser::delete_user(idUser) |
| 88 | + assert(response.get_status == "error") |
| 89 | + assert(response.get_message == message_expect ) |
| 90 | + end |
| 91 | + |
| 92 | + def test_AccountUser_update_user |
| 93 | + params = {"url_api" => 'http://api.test.sw.com.mx', "token" => ENV["SDKTEST_TOKEN"]} |
| 94 | + AccountUser::set(params) |
| 95 | + idUser = "b9e42c65-4afa-45a2-9b0d-d67b1373a7f4" |
| 96 | + name = "Prueba UT Hijo Python Actualizado" |
| 97 | + taxId = "XAXX010101002" |
| 98 | + phone = "0000000001" |
| 99 | + message_expect = "No es posible actualizar, los datos enviados son identicos a los actuales" |
| 100 | + response = AccountUser::update_user(idUser,name,taxId,nil,phone,false) |
| 101 | + assert(response.get_message == message_expect ) |
| 102 | + end |
| 103 | +end |
0 commit comments