From 697a88548174428a15f91ece4150994e4e488f6f Mon Sep 17 00:00:00 2001 From: Isaac Lewis Date: Wed, 28 Mar 2018 17:57:06 -0700 Subject: [PATCH] update tests --- lib/syspro/get_logon_profile.rb | 2 +- lib/syspro/get_version.rb | 2 +- lib/syspro/logon.rb | 2 +- lib/syspro/syspro_client.rb | 8 ++++---- test/client_test.rb | 2 +- test/logoff_test.rb | 18 ++++++++++++++++++ test/logon_test.rb | 2 +- 7 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 test/logoff_test.rb diff --git a/lib/syspro/get_logon_profile.rb b/lib/syspro/get_logon_profile.rb index 21f6ced..12e8dda 100644 --- a/lib/syspro/get_logon_profile.rb +++ b/lib/syspro/get_logon_profile.rb @@ -13,7 +13,7 @@ module Syspro def self.parse_response(resp) doc = resp.data - user_profile = UserProfile.new( + UserProfile.new( doc.xpath("//CompanyName").text, doc.xpath("//OperatorCode").text, doc.xpath("//OperatorGroup").text, diff --git a/lib/syspro/get_version.rb b/lib/syspro/get_version.rb index 70af958..4413bfc 100644 --- a/lib/syspro/get_version.rb +++ b/lib/syspro/get_version.rb @@ -2,7 +2,7 @@ module Syspro class GetVersion < ApiResource def self.get_version resp = self.request(:get, resource_url) - version = VersionObject.new(resp[0].http_body) + VersionObject.new(resp[0].http_body) end def resource_url diff --git a/lib/syspro/logon.rb b/lib/syspro/logon.rb index 8b56c5f..371067e 100644 --- a/lib/syspro/logon.rb +++ b/lib/syspro/logon.rb @@ -8,7 +8,7 @@ module Syspro "CompanyPassword" => company_password } resp = self.request(:get, resource_url, params) - user_id = UserIdObject.new(resp[0].http_body) + UserIdObject.new(resp[0].http_body) end def resource_url diff --git a/lib/syspro/syspro_client.rb b/lib/syspro/syspro_client.rb index a8edd8c..8e7dc9e 100644 --- a/lib/syspro/syspro_client.rb +++ b/lib/syspro/syspro_client.rb @@ -2,19 +2,19 @@ module Syspro class SysproClient attr_accessor :conn, :api_base + @verify_ssl_warned = false + def initialize(conn = nil) self.conn = conn || self.class.default_conn @system_profiler = SystemProfiler.new end def logon(username, password, company_id, company_password) - logon_getter = Syspro::ApiOperations::Logon.new - logon_getter.logon(username, password, company_id, company_password) + Syspro::Logon.logon(username, password, company_id, company_password) end def get_syspro_version - version_getter = Syspro::ApiOperations::GetVersion.new - version_getter.get_version + Syspro::GetVersion.get_version end def self.active_client diff --git a/test/client_test.rb b/test/client_test.rb index 75537b0..654b234 100644 --- a/test/client_test.rb +++ b/test/client_test.rb @@ -3,6 +3,6 @@ require "test_helper" class SysproClientTest < Minitest::Test def test_get_syspro_version client = ::Syspro::SysproClient.new - assert_match /(\d+\.)?(\d+\.)?(\d+\.)?(\d+)/, client.get_syspro_version.version + assert_match (/(\d+\.)?(\d+\.)?(\d+\.)?(\d+)/), client.get_syspro_version.version end end diff --git a/test/logoff_test.rb b/test/logoff_test.rb new file mode 100644 index 0000000..93092ac --- /dev/null +++ b/test/logoff_test.rb @@ -0,0 +1,18 @@ +require "test_helper" + +class LogoffTest < Minitest::Test + def test_successful_logoff + username = "wland" + password = "piperita2016" + company = "L" + company_password = "" + + uid = Syspro::Logon.logon(username, password, company, company_password) + assert_equal true, Syspro::Logoff.logoff(uid.guid) + end + + def test_logoff_error + assert_kind_of String, Syspro::Logoff.logoff('1BB5B3050954BB459A5D034DB5CC386980') + end +end + diff --git a/test/logon_test.rb b/test/logon_test.rb index 4248053..8e34233 100644 --- a/test/logon_test.rb +++ b/test/logon_test.rb @@ -8,7 +8,7 @@ class LogonTest < Minitest::Test company_password = "" client = ::Syspro::SysproClient.new - assert_match /([A-Z0-9]{33})\w/, client.logon(username, password, company, company_password).guid + assert_match (/([A-Z0-9]{33})\w/), client.logon(username, password, company, company_password).guid end end -- libgit2 0.21.4