Commit 697a88548174428a15f91ece4150994e4e488f6f

Authored by Isaac Lewis
1 parent a61f2fc8

update tests

lib/syspro/get_logon_profile.rb
@@ -13,7 +13,7 @@ module Syspro @@ -13,7 +13,7 @@ module Syspro
13 def self.parse_response(resp) 13 def self.parse_response(resp)
14 doc = resp.data 14 doc = resp.data
15 15
16 - user_profile = UserProfile.new( 16 + UserProfile.new(
17 doc.xpath("//CompanyName").text, 17 doc.xpath("//CompanyName").text,
18 doc.xpath("//OperatorCode").text, 18 doc.xpath("//OperatorCode").text,
19 doc.xpath("//OperatorGroup").text, 19 doc.xpath("//OperatorGroup").text,
lib/syspro/get_version.rb
@@ -2,7 +2,7 @@ module Syspro @@ -2,7 +2,7 @@ module Syspro
2 class GetVersion < ApiResource 2 class GetVersion < ApiResource
3 def self.get_version 3 def self.get_version
4 resp = self.request(:get, resource_url) 4 resp = self.request(:get, resource_url)
5 - version = VersionObject.new(resp[0].http_body) 5 + VersionObject.new(resp[0].http_body)
6 end 6 end
7 7
8 def resource_url 8 def resource_url
lib/syspro/logon.rb
@@ -8,7 +8,7 @@ module Syspro @@ -8,7 +8,7 @@ module Syspro
8 "CompanyPassword" => company_password 8 "CompanyPassword" => company_password
9 } 9 }
10 resp = self.request(:get, resource_url, params) 10 resp = self.request(:get, resource_url, params)
11 - user_id = UserIdObject.new(resp[0].http_body) 11 + UserIdObject.new(resp[0].http_body)
12 end 12 end
13 13
14 def resource_url 14 def resource_url
lib/syspro/syspro_client.rb
@@ -2,19 +2,19 @@ module Syspro @@ -2,19 +2,19 @@ module Syspro
2 class SysproClient 2 class SysproClient
3 attr_accessor :conn, :api_base 3 attr_accessor :conn, :api_base
4 4
  5 + @verify_ssl_warned = false
  6 +
5 def initialize(conn = nil) 7 def initialize(conn = nil)
6 self.conn = conn || self.class.default_conn 8 self.conn = conn || self.class.default_conn
7 @system_profiler = SystemProfiler.new 9 @system_profiler = SystemProfiler.new
8 end 10 end
9 11
10 def logon(username, password, company_id, company_password) 12 def logon(username, password, company_id, company_password)
11 - logon_getter = Syspro::ApiOperations::Logon.new  
12 - logon_getter.logon(username, password, company_id, company_password) 13 + Syspro::Logon.logon(username, password, company_id, company_password)
13 end 14 end
14 15
15 def get_syspro_version 16 def get_syspro_version
16 - version_getter = Syspro::ApiOperations::GetVersion.new  
17 - version_getter.get_version 17 + Syspro::GetVersion.get_version
18 end 18 end
19 19
20 def self.active_client 20 def self.active_client
test/client_test.rb
@@ -3,6 +3,6 @@ require &quot;test_helper&quot; @@ -3,6 +3,6 @@ require &quot;test_helper&quot;
3 class SysproClientTest < Minitest::Test 3 class SysproClientTest < Minitest::Test
4 def test_get_syspro_version 4 def test_get_syspro_version
5 client = ::Syspro::SysproClient.new 5 client = ::Syspro::SysproClient.new
6 - assert_match /(\d+\.)?(\d+\.)?(\d+\.)?(\d+)/, client.get_syspro_version.version 6 + assert_match (/(\d+\.)?(\d+\.)?(\d+\.)?(\d+)/), client.get_syspro_version.version
7 end 7 end
8 end 8 end
test/logoff_test.rb 0 → 100644
  1 +require "test_helper"
  2 +
  3 +class LogoffTest < Minitest::Test
  4 + def test_successful_logoff
  5 + username = "wland"
  6 + password = "piperita2016"
  7 + company = "L"
  8 + company_password = ""
  9 +
  10 + uid = Syspro::Logon.logon(username, password, company, company_password)
  11 + assert_equal true, Syspro::Logoff.logoff(uid.guid)
  12 + end
  13 +
  14 + def test_logoff_error
  15 + assert_kind_of String, Syspro::Logoff.logoff('1BB5B3050954BB459A5D034DB5CC386980')
  16 + end
  17 +end
  18 +
test/logon_test.rb
@@ -8,7 +8,7 @@ class LogonTest &lt; Minitest::Test @@ -8,7 +8,7 @@ class LogonTest &lt; Minitest::Test
8 company_password = "" 8 company_password = ""
9 client = ::Syspro::SysproClient.new 9 client = ::Syspro::SysproClient.new
10 10
11 - assert_match /([A-Z0-9]{33})\w/, client.logon(username, password, company, company_password).guid 11 + assert_match (/([A-Z0-9]{33})\w/), client.logon(username, password, company, company_password).guid
12 end 12 end
13 end 13 end
14 14