portal_module 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/Gemfile +13 -0
- data/Guardfile +24 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +240 -0
- data/Rakefile +101 -0
- data/bin/portal_module +10 -0
- data/lib/portal_module/assertable.rb +37 -0
- data/lib/portal_module/cli.rb +35 -0
- data/lib/portal_module/client.rb +110 -0
- data/lib/portal_module/command/client_access.rb +41 -0
- data/lib/portal_module/command/config.rb +323 -0
- data/lib/portal_module/command/dts.rb +70 -0
- data/lib/portal_module/command/loan_entry.rb +66 -0
- data/lib/portal_module/command.rb +16 -0
- data/lib/portal_module/config_helper.rb +32 -0
- data/lib/portal_module/dts.rb +99 -0
- data/lib/portal_module/loan_entry.rb +101 -0
- data/lib/portal_module/page_factory.rb +27 -0
- data/lib/portal_module/pages/data_transformation_page.rb +84 -0
- data/lib/portal_module/pages/login_page.rb +73 -0
- data/lib/portal_module/pages/prequal_setup_page.rb +77 -0
- data/lib/portal_module/pages.rb +90 -0
- data/lib/portal_module/rake/dts_tasks.rb +166 -0
- data/lib/portal_module/rake/loan_entry_tasks.rb +166 -0
- data/lib/portal_module/rake.rb +16 -0
- data/lib/portal_module/version.rb +3 -0
- data/lib/portal_module.rb +251 -0
- data/portal_module.gemspec +33 -0
- data/spec/data/dts_import.xml +1 -0
- data/spec/data/le_import.xml +1 -0
- data/spec/lib/portal_module/cli_spec.rb +35 -0
- data/spec/lib/portal_module/client_spec.rb +126 -0
- data/spec/lib/portal_module/command/config_spec.rb +474 -0
- data/spec/lib/portal_module/command/dts_spec.rb +98 -0
- data/spec/lib/portal_module/command/loan_entry_spec.rb +98 -0
- data/spec/lib/portal_module/dts_spec.rb +145 -0
- data/spec/lib/portal_module/loan_entry_spec.rb +113 -0
- data/spec/lib/portal_module_spec.rb +175 -0
- data/spec/spec_helper.rb +52 -0
- data/spec/support/asserts.rb +10 -0
- data/spec/support/dirs.rb +53 -0
- data/spec/support/helpers.rb +44 -0
- data/spec/support/mocks.rb +106 -0
- metadata +247 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: dts.rb
|
3
|
+
# Purpose:: DTS command line interface
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-27
|
6
|
+
##############################################################################
|
7
|
+
|
8
|
+
module PortalModule
|
9
|
+
module Command
|
10
|
+
class Dts < Thor
|
11
|
+
include ClientAccess
|
12
|
+
|
13
|
+
class_option :environment, :banner => "dev", :aliases => :e
|
14
|
+
|
15
|
+
desc "upload <org> <filepath>",
|
16
|
+
"Upload a DTS configuration file into the environment"
|
17
|
+
long_desc <<-LD
|
18
|
+
Upload a DTS configuration file into the environment.
|
19
|
+
|
20
|
+
<org> name of the Org Unit to import to.
|
21
|
+
The org must be available in the configuration.
|
22
|
+
See <config add org>, <config show org>.
|
23
|
+
|
24
|
+
<filepath> is a path to a XML configuration file to import.
|
25
|
+
|
26
|
+
With -e <env>, sets the environment to work with.
|
27
|
+
|
28
|
+
Examples:
|
29
|
+
|
30
|
+
* portal_module dts upload -e dev 'Test Org' path/to/my/file.xml
|
31
|
+
|
32
|
+
* portal_module dts upload -e dev 'Test Org' 'path with space/to/my/file.xml'
|
33
|
+
LD
|
34
|
+
def upload org, filepath
|
35
|
+
cl = client.dts
|
36
|
+
cl.upload org, filepath
|
37
|
+
|
38
|
+
ensure
|
39
|
+
client.logout
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "download <org> <filepath>",
|
43
|
+
"Export a DTS configuration file from the environment"
|
44
|
+
long_desc <<-LD
|
45
|
+
Download a DTS configuration file from the environment.
|
46
|
+
|
47
|
+
<org> name of the Org Unit to export from.
|
48
|
+
The org must be available in the configuration.
|
49
|
+
See <config add org>, <config show org>.
|
50
|
+
|
51
|
+
<filepath> path where the XML configuration file will be exported to.
|
52
|
+
|
53
|
+
With -e <env>, sets the environment to work with.
|
54
|
+
|
55
|
+
Examples:
|
56
|
+
|
57
|
+
* portal_module dts download -e dev 'Test Org' path/to/my/file.xml
|
58
|
+
|
59
|
+
* portal_module dts download -e dev 'Test Org' 'path with space/to/my/file.xml'
|
60
|
+
LD
|
61
|
+
def download org, filepath
|
62
|
+
cl = client.dts
|
63
|
+
cl.download org, filepath
|
64
|
+
|
65
|
+
ensure
|
66
|
+
client.logout
|
67
|
+
end
|
68
|
+
end # Dts
|
69
|
+
end # Command
|
70
|
+
end # PortalModule
|
@@ -0,0 +1,66 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: loan_entry.rb
|
3
|
+
# Purpose:: LoanEntry command line interface
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-29
|
6
|
+
##############################################################################
|
7
|
+
|
8
|
+
module PortalModule
|
9
|
+
module Command
|
10
|
+
class LoanEntry < Thor
|
11
|
+
include ClientAccess
|
12
|
+
|
13
|
+
class_option :environment, :banner => "dev", :aliases => :e
|
14
|
+
|
15
|
+
desc "upload <org> <filepath>",
|
16
|
+
"Upload a Loan Entry configuration file into the environment"
|
17
|
+
long_desc <<-LD
|
18
|
+
Import a Loan Entry configuration file into the environment.
|
19
|
+
|
20
|
+
<org> name of Org Unit to import changes to.
|
21
|
+
|
22
|
+
<filepath> is a path to a XML configuration file to import.
|
23
|
+
|
24
|
+
With -e <env>, sets the environment to work with.
|
25
|
+
|
26
|
+
Examples:
|
27
|
+
|
28
|
+
* portal_module loan_entry upload -e dev 'Test Org' path/to/my/file.xml
|
29
|
+
|
30
|
+
* portal_module loan_entry upload -e dev 'Test Org' 'path with space/to/my/file.xml'
|
31
|
+
LD
|
32
|
+
def upload org, filepath
|
33
|
+
cs = client.loan_entry
|
34
|
+
cs.upload org, filepath
|
35
|
+
|
36
|
+
ensure
|
37
|
+
client.logout
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "download <org> <filepath>",
|
41
|
+
"Download a Loan Entry configuration file from the environment"
|
42
|
+
long_desc <<-LD
|
43
|
+
Export a Loan Entry configuration file from the environment.
|
44
|
+
|
45
|
+
<org> name of Org Unit to export changes from.
|
46
|
+
|
47
|
+
<filepath> path where the XML configuration file will be exported to.
|
48
|
+
|
49
|
+
With -e <env>, sets the environment to work with.
|
50
|
+
|
51
|
+
Examples:
|
52
|
+
|
53
|
+
* portal_module loan_entry download -e dev 'Test Org' path/to/my/file.xml
|
54
|
+
|
55
|
+
* portal_module loan_entry download -e dev 'Test Org' 'path with space/to/my/file.xml'
|
56
|
+
LD
|
57
|
+
def download org, filepath
|
58
|
+
cs = client.loan_entry
|
59
|
+
cs.download org, filepath
|
60
|
+
|
61
|
+
ensure
|
62
|
+
client.logout
|
63
|
+
end
|
64
|
+
end # class
|
65
|
+
end # Command
|
66
|
+
end # module
|
@@ -0,0 +1,16 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: command.rb
|
3
|
+
# Purpose:: Command module for Thor commands
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 03/28/2015
|
6
|
+
##############################################################################
|
7
|
+
|
8
|
+
module PortalModule
|
9
|
+
module Command
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require_relative 'command/client_access'
|
14
|
+
require_relative 'command/config'
|
15
|
+
require_relative 'command/dts'
|
16
|
+
require_relative 'command/loan_entry'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: config_helper.rb
|
3
|
+
# Purpose:: Configuration object wrapper
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-29
|
6
|
+
#
|
7
|
+
##############################################################################
|
8
|
+
|
9
|
+
module PortalModule
|
10
|
+
class ConfigHelper
|
11
|
+
|
12
|
+
def self.env=(env)
|
13
|
+
@env = env.to_sym
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.env
|
17
|
+
@env ||= PortalModule.configuration.default_environment
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.page_factory=(factory)
|
21
|
+
@page_factory = factory
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.page_factory
|
25
|
+
@page_factory ||= PageFactory.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.credentials
|
29
|
+
PortalModule.configuration.credentials[env]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end # PortalModule
|
@@ -0,0 +1,99 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: dts.rb
|
3
|
+
# Purpose:: Interface to DTS functionality in portal module
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-27
|
6
|
+
##############################################################################
|
7
|
+
|
8
|
+
require 'portal_module/pages'
|
9
|
+
require 'portal_module/assertable'
|
10
|
+
|
11
|
+
module PortalModule
|
12
|
+
|
13
|
+
class Dts
|
14
|
+
include Assertable
|
15
|
+
|
16
|
+
DL_FILENAME = '2-LatestDTS.xml'
|
17
|
+
|
18
|
+
attr_reader :page_factory
|
19
|
+
|
20
|
+
def initialize(page_factory)
|
21
|
+
@page_factory = page_factory
|
22
|
+
end
|
23
|
+
|
24
|
+
def save
|
25
|
+
dts_page.save
|
26
|
+
end
|
27
|
+
|
28
|
+
def activate
|
29
|
+
dts_page.activate
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_org org
|
33
|
+
assert_org_is_configured org
|
34
|
+
dts_page.load_org(org_string(org))
|
35
|
+
end
|
36
|
+
|
37
|
+
def download org, file_path
|
38
|
+
assert_org_is_configured org
|
39
|
+
assert_dl_dir_is_configured
|
40
|
+
assert_dir_exists file_path
|
41
|
+
|
42
|
+
dts_page
|
43
|
+
.load_org(org_string(org))
|
44
|
+
.download
|
45
|
+
|
46
|
+
file_path = Pathname(file_path)
|
47
|
+
file_path = file_path + DL_FILENAME if file_path.directory?
|
48
|
+
|
49
|
+
dl_file = download_dir + DL_FILENAME
|
50
|
+
wait_for_file(dl_file, PortalModule.configuration.download_timeout)
|
51
|
+
assert_file_exists dl_file
|
52
|
+
|
53
|
+
FileUtils.mv dl_file, file_path
|
54
|
+
|
55
|
+
rescue Exception => e
|
56
|
+
if e.message.include? 'No such file or directory'
|
57
|
+
raise IOError, "No such directory - #{file_path}"
|
58
|
+
else
|
59
|
+
raise e
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Import DTS configurations into the current environment from a file.
|
65
|
+
|
66
|
+
def upload org, file_path
|
67
|
+
assert_org_is_configured org
|
68
|
+
assert_file_exists file_path
|
69
|
+
|
70
|
+
dts_page
|
71
|
+
.load_org(org_string(org))
|
72
|
+
.upload(Pathname(file_path).expand_path)
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def dts_page
|
78
|
+
page_factory.dts_page
|
79
|
+
end
|
80
|
+
|
81
|
+
def download_dir
|
82
|
+
Pathname(PortalModule.configuration.download_dir)
|
83
|
+
end
|
84
|
+
|
85
|
+
def org_string org
|
86
|
+
orgid = PortalModule.configuration.orgs[org]
|
87
|
+
orgstr = "#{orgid}~#{org}"
|
88
|
+
end
|
89
|
+
|
90
|
+
def wait_for_file(file_path, timeout_secs)
|
91
|
+
stop_time = Time.now + timeout_secs
|
92
|
+
file_path = Pathname(file_path)
|
93
|
+
while !file_path.exist?
|
94
|
+
break if stop_time <= Time.now
|
95
|
+
sleep 1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end # class Dts
|
99
|
+
end # module
|
@@ -0,0 +1,101 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: loan_entry.rb
|
3
|
+
# Purpose:: filedescription
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-27
|
6
|
+
##############################################################################
|
7
|
+
|
8
|
+
require 'portal_module/pages'
|
9
|
+
require 'portal_module/assertable'
|
10
|
+
|
11
|
+
module PortalModule
|
12
|
+
|
13
|
+
class LoanEntry
|
14
|
+
include Assertable
|
15
|
+
|
16
|
+
DL_FILENAME = '2-LatestPrequal.xml'
|
17
|
+
|
18
|
+
attr_reader :page_factory
|
19
|
+
|
20
|
+
def initialize page_factory
|
21
|
+
@page_factory = page_factory
|
22
|
+
end
|
23
|
+
|
24
|
+
def activate
|
25
|
+
loan_entry_page
|
26
|
+
.activate
|
27
|
+
end
|
28
|
+
|
29
|
+
def set_org org
|
30
|
+
assert_org_is_configured org
|
31
|
+
|
32
|
+
loan_entry_page.load_org(org_string(org))
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Export loan entry data for an org unit to a file
|
37
|
+
|
38
|
+
def download org, file_path
|
39
|
+
assert_org_is_configured org
|
40
|
+
assert_dl_dir_is_configured
|
41
|
+
assert_dir_exists file_path
|
42
|
+
|
43
|
+
loan_entry_page
|
44
|
+
.load_org(org_string(org))
|
45
|
+
.download
|
46
|
+
|
47
|
+
file_path = Pathname(file_path)
|
48
|
+
file_path = file_path + DL_FILENAME if file_path.directory?
|
49
|
+
|
50
|
+
dl_file = download_dir + DL_FILENAME
|
51
|
+
wait_for_file(dl_file, PortalModule.configuration.download_timeout)
|
52
|
+
assert_file_exists dl_file
|
53
|
+
|
54
|
+
FileUtils.mv dl_file, file_path
|
55
|
+
|
56
|
+
rescue Exception => e
|
57
|
+
if e.message.include? 'No such file or directory'
|
58
|
+
raise IOError, "No such directory - #{file_path}"
|
59
|
+
else
|
60
|
+
raise e
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# Import loan entry data from a file
|
66
|
+
#
|
67
|
+
|
68
|
+
def upload org, file_path
|
69
|
+
assert_org_is_configured org
|
70
|
+
assert_file_exists file_path
|
71
|
+
|
72
|
+
loan_entry_page
|
73
|
+
.load_org(org_string(org))
|
74
|
+
.upload(Pathname(file_path).expand_path)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def loan_entry_page
|
80
|
+
page_factory.loan_entry_page
|
81
|
+
end
|
82
|
+
|
83
|
+
def download_dir
|
84
|
+
Pathname(PortalModule.configuration.download_dir)
|
85
|
+
end
|
86
|
+
|
87
|
+
def org_string org
|
88
|
+
orgid = PortalModule.configuration.orgs[org]
|
89
|
+
orgstr = "#{orgid}~#{org}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def wait_for_file(file_path, timeout_secs)
|
93
|
+
stop_time = Time.now + timeout_secs
|
94
|
+
file_path = Pathname(file_path)
|
95
|
+
while !file_path.exist?
|
96
|
+
break if stop_time <= Time.now
|
97
|
+
sleep 1
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end # class
|
101
|
+
end # module
|
@@ -0,0 +1,27 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: page_factory.rb
|
3
|
+
# Purpose:: Provides Page objects
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-29
|
6
|
+
#
|
7
|
+
##############################################################################
|
8
|
+
|
9
|
+
require 'portal_module/pages'
|
10
|
+
|
11
|
+
module PortalModule
|
12
|
+
class PageFactory
|
13
|
+
include PortalModule::Pages
|
14
|
+
|
15
|
+
def login_page(goto_page = true)
|
16
|
+
return Pages::LoginPage.new(browser, goto_page)
|
17
|
+
end
|
18
|
+
|
19
|
+
def dts_page(goto_page = true)
|
20
|
+
return Pages::DataTransformationPage.new(browser, goto_page)
|
21
|
+
end
|
22
|
+
|
23
|
+
def loan_entry_page(goto_page = true)
|
24
|
+
return Pages::PrequalSetupPage.new(browser, goto_page)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end # PortalModule
|
@@ -0,0 +1,84 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: data_transformation_page.rb
|
3
|
+
# Purpose:: DTS page for PortalModule
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-28
|
6
|
+
##############################################################################
|
7
|
+
require 'page-object'
|
8
|
+
|
9
|
+
module PortalModule::Pages
|
10
|
+
class DataTransformationPage
|
11
|
+
include PageObject
|
12
|
+
|
13
|
+
# If page_url is not set, page_object will not navigate to this page
|
14
|
+
# when visit is true.
|
15
|
+
page_url(:get_dynamic_url)
|
16
|
+
|
17
|
+
def get_dynamic_url
|
18
|
+
PortalModule.configuration.url(DataTransformationPage)
|
19
|
+
end
|
20
|
+
|
21
|
+
span(:viewing_span,
|
22
|
+
id: 'ctl00_ContentPlaceHolder1_lblOrganizationName')
|
23
|
+
|
24
|
+
button(:save_button,
|
25
|
+
id: 'ctl00_ContentPlaceHolder1_btnSave')
|
26
|
+
|
27
|
+
button(:activate_button,
|
28
|
+
id: 'ctl00_ContentPlaceHolder1_btnVersion')
|
29
|
+
|
30
|
+
button(:download_button,
|
31
|
+
id: 'ctl00_ContentPlaceHolder1_btnDownload')
|
32
|
+
|
33
|
+
# Search Orgs
|
34
|
+
text_field(:search_text,
|
35
|
+
id: 'ctl00_ContentPlaceHolder1_txtSrchText')
|
36
|
+
|
37
|
+
button(:search_button,
|
38
|
+
id: 'ctl00_ContentPlaceHolder1_btnSearch')
|
39
|
+
|
40
|
+
# File Upload
|
41
|
+
file_field(:file_input,
|
42
|
+
id: 'ctl00_ContentPlaceHolder1_FileUploader')
|
43
|
+
|
44
|
+
button(:upload_button,
|
45
|
+
id: 'ctl00_ContentPlaceHolder1_btnUploadXMLFile')
|
46
|
+
|
47
|
+
|
48
|
+
def save
|
49
|
+
self.save_button
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
def activate
|
54
|
+
self.activate_button
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
58
|
+
def download
|
59
|
+
self.download_button
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_org org_string
|
64
|
+
org_name = org_string.split('~')[1]
|
65
|
+
return self if viewing_span == org_name
|
66
|
+
|
67
|
+
self.search_text = org_string
|
68
|
+
self.search_button
|
69
|
+
|
70
|
+
viewing_span_element.wait_until(120, "Org not loaded - #{org_name}") do
|
71
|
+
viewing_span == org_name
|
72
|
+
end
|
73
|
+
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
def upload file_path
|
78
|
+
self.file_input = file_path
|
79
|
+
self.upload_button
|
80
|
+
self
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end # module Pages
|
84
|
+
|