boq_com_au 0.3.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f547e1eca5d228aa0fbe37a82921b33370977e513f209b5e57bab82d8347b6bb
4
- data.tar.gz: 0aa18118dc2ce6a0726fdbac97bff153f89cf7a55febf13240a5a2237447ecf5
3
+ metadata.gz: 7dbfa387d610f682d7da5ac4cc759933199a95e07fa2a3ed59a371a81b8fb14c
4
+ data.tar.gz: 5fb79aa2173d74a2a5bc5caed23aa36d877fd4addd817625e81637ac1b3eef67
5
5
  SHA512:
6
- metadata.gz: 31711622ea4cf7f3ffbc005b00abe07c7859529badc32b338defa02a6fa65713ed9b10674f671b545d65ac0ed4933ac622d751e02dd3c919fa7b5fc67b678779
7
- data.tar.gz: 537ee3dad673b7a379c15da75b271b3e5bff94a55fccbe94fb7c633168cd7e14a655892e1eac3c06284404122e6ae02098af35db237da2ca23e4a8e990cbb625
6
+ metadata.gz: d73852294ffd68b289400f939be9046d7d45037646c0ace02aaab989b92b46097d4d6a84a8bc9857740d7ac06056a8dbf20ab76aa90f0fc3535bf82170d62a5e
7
+ data.tar.gz: 36866d193c771d928993c5f9b1000624b827c4ed400470baf57ccadfc8faff4c4d54a4c8ec34afc0c8c9b400652601f08a37b4a35175a6ee276e2d7350814d5f
data/CHANGELOG CHANGED
@@ -1,5 +1,27 @@
1
1
  # boq_com_au/CHANGELOG
2
2
 
3
+ ## 20261115
4
+
5
+ 0.4.1: ~ BoqComAu::Account#login and #download_transactions name every argument missing at once, as an ArgumentError.
6
+
7
+ 1. + BoqComAu::Account#validate_args
8
+ 2. + BoqComAu::Account#login: Calls validate_args(username:, password:), then WebAccount#login.
9
+ 3. - BoqComAu::Account#username, #password: WebAccount's readers are used, nil where not given.
10
+ 4. ~ BoqComAu::Account#download_transactions: Calls validate_args(account_number:).
11
+ 5. ~ test/BoqComAu/Account_test.rb: One missing and both missing are named by login, given to new or to login itself; a nil account_number is named by download_transactions; username and password are nil where not given.
12
+ 6. ~ README.md, Account.rb's notes: login raises ArgumentError naming every one missing.
13
+ 7. ~ Account.rb's notes: Chosen, which draws BOQ's dropdowns, is said to be a JavaScript library, as otherwise it reads as the word "chosen".
14
+ 8. ~ BoqComAu::VERSION: /0.4.0/0.4.1/
15
+
16
+ 0.4.0: - BoqComAu::Account#initialize: Now uses superclass WebAccount.
17
+
18
+ 1. ~ boq_com_au.gemspec: webaccount /'~> 0.7'/'~> 0.8'/
19
+ 2. - BoqComAu::Account#initialize, WebAccount's reading PAGE_SELECTORS itself.
20
+ 3. ~ test/BoqComAu/Account_test.rb: A login page URL and a selector given win over BOQ's, the rest staying BOQ's; /logs in to BOQ, whatever else is passed to WebAccount/uses BOQ's selectors where none is given/.
21
+ 4. ~ README.md: The keywords of new win over PAGE_SELECTORS.
22
+ 5. ~ BoqComAu::VERSION: /0.3.0/0.4.0/
23
+
24
+
3
25
  ## 20261111
4
26
 
5
27
  0.3.0: ~ BoqComAu::Account uses WebAccount 0.7.0's browser options and download waiting, so as it runs in Firefox as well as Chrome; /chrome_profile_directory:/profile_directory:/.
data/README.md CHANGED
@@ -58,7 +58,7 @@ The username is the Customer Access Number. It and the password are given, or se
58
58
  boq_account = BoqComAu::Account.new(username: customer_access_number, password: password)
59
59
  boq_account.username, boq_account.password = customer_access_number, password
60
60
  ```
61
- Where either is missing, `login` stops, saying which.
61
+ Where either is missing, `login` raises ArgumentError before starting the browser, naming every one missing.
62
62
 
63
63
  ### The browser
64
64
 
@@ -79,6 +79,11 @@ Where BOQ asks for a one-time code after logging on, `login` waits up to 30 seco
79
79
 
80
80
  The selectors were taken from the live site. BOQ's ids are generated, so things are found by their labels and text, and a change to the wording of the site will break it.
81
81
 
82
+ Each key of `BoqComAu::Account::PAGE_SELECTORS` is also a keyword of `new`, which wins over BOQ's, so as a login page selector which has changed can be given without waiting for a new version:
83
+ ```ruby
84
+ BoqComAu::Account.new(login_page_submit_button_selector: {id: 'btnLogOn'})
85
+ ```
86
+
82
87
  The tests cover only what doesn't depend on BOQ's site.
83
88
 
84
89
  ## Contributing
data/boq_com_au.gemspec CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
 
39
39
  spec.dependencies = [
40
40
  ['selenium-webdriver', '>= 4.0'],
41
- ['webaccount', '~> 0.7']
41
+ ['webaccount', '~> 0.8']
42
42
  ]
43
43
 
44
44
  spec.development_dependencies = %w{
@@ -5,10 +5,10 @@
5
5
  # 1. The login page's ids and names (id4, 8, ...) appear to be generated, so the fields are found by their labels.
6
6
  # 2. The ids and names after login (id121, 74, ...) appear to be generated too, so TRANSACTIONS_SELECTORS find things by their text.
7
7
  # 3. BankFast's links are javascript:void(0) where they aren't the session's key and a callback number, and some, such as Transaction History, are in a menu which is closed. A link which isn't displayed is clicked by JavaScript.
8
- # 4. Dropdowns are Chosen's, which hides the select and draws its own: <select id>_chosen, opened by its a.chosen-single and chosen from its li.active-result. A select which is displayed is used as it is.
8
+ # 4. Dropdowns are drawn by Chosen, a JavaScript library, which hides the select and draws its own: <select id>_chosen, opened by its a.chosen-single and chosen from its li.active-result. A select which is displayed is used as it is.
9
9
  # 5. Where a one-time code is asked for after logging on, login() waits default_wait_timeout seconds for it to be entered by hand.
10
10
  # 6. The browser, Chrome or Firefox, is WebAccount's: given a profile_directory, it's started with that profile, kept between runs, so as the bank sees a returning browser rather than a fresh automated one. It downloads into download_directory without asking, and opens nothing it downloads.
11
- # 7. A username or password not given stops login, saying which is missing.
11
+ # 7. A username or password not given stops login before the browser is started, naming every one missing.
12
12
  # 8. BOQ names the exported file after the account number and the date, as 12345678_20261103.csv, and the browser numbers a second download of the same name; so the newest finished CSV file to appear in download_directory once Download is clicked is taken to be it.
13
13
  # 9. Dates are BOQ's own, as shown on choosing the account, unless a period or a date is given; then they're set under Advanced Search and searched on before exporting.
14
14
 
@@ -37,16 +37,14 @@ module BoqComAu
37
37
  download_button: {xpath: '//*[self::a or self::button][normalize-space()="Download"] | //input[@value="Download"]'}
38
38
  }
39
39
 
40
- def username
41
- @username || raise("No username: it's given as username:.")
42
- end
43
-
44
- def password
45
- @password || raise("No password: it's given as password:.")
40
+ def login(username: nil, password: nil)
41
+ validate_args(username: username || self.username, password: password || self.password)
42
+ super
46
43
  end
47
44
 
48
45
  # period is :all, the last year, or :last_month. Without it, from_date and to_date, either of which defaults to a year ago and today respectively where the other is given. Returns the name of the CSV file downloaded.
49
46
  def download_transactions(account_number:, period: nil, from_date: nil, to_date: nil)
47
+ validate_args(account_number: account_number)
50
48
  from_date, to_date = dates(period: period, from_date: from_date, to_date: to_date)
51
49
  get_transactions_page
52
50
  select_bank_account(account_number)
@@ -59,8 +57,15 @@ module BoqComAu
59
57
 
60
58
  private
61
59
 
62
- def initialize(username: nil, password: nil, **web_account_args)
63
- super(username: username, password: password, **web_account_args, **PAGE_SELECTORS)
60
+ def validate_args(args)
61
+ missing_args = []
62
+ args.each do |arg_name, value|
63
+ missing_args << arg_name unless value
64
+ end
65
+ return if missing_args.empty?
66
+ aggregate_error = missing_args.join(', ')
67
+ copula = missing_args.count > 1 ? 'are' : 'is'
68
+ raise ArgumentError, "#{aggregate_error} #{copula} missing."
64
69
  end
65
70
 
66
71
  # page interaction
@@ -2,5 +2,5 @@
2
2
  # BoqComAu::VERSION
3
3
 
4
4
  module BoqComAu
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.1'
6
6
  end
@@ -81,17 +81,34 @@ describe BoqComAu::Account do
81
81
  _(account.password).must_equal('secret')
82
82
  end
83
83
 
84
- it "say which is missing where they're not given, rather than reading the environment" do
84
+ it "are nil where they're not given, rather than read from the environment" do
85
85
  ENV['BOQ_USERNAME'], ENV['BOQ_PASSWORD'] = 'customer', 'secret'
86
86
  account = BoqComAu::Account.new
87
- _(_{account.username}.must_raise(RuntimeError).message).must_include('No username')
88
- _(_{account.password}.must_raise(RuntimeError).message).must_include('No password')
87
+ _(account.username).must_be_nil
88
+ _(account.password).must_be_nil
89
89
  ensure
90
90
  ENV.delete('BOQ_USERNAME')
91
91
  ENV.delete('BOQ_PASSWORD')
92
92
  end
93
93
  end
94
94
 
95
+ describe "#login" do
96
+ it "names the one missing, before starting the browser" do
97
+ account = BoqComAu::Account.new(username: 'customer')
98
+ _(_{account.login}.must_raise(ArgumentError).message).must_equal('password is missing.')
99
+ _(account.instance_variable_get(:@driver)).must_be_nil
100
+ end
101
+
102
+ it "names both where both are missing" do
103
+ _(_{BoqComAu::Account.new.login}.must_raise(ArgumentError).message).must_equal('username, password are missing.')
104
+ end
105
+
106
+ it "takes either given to login itself as given" do
107
+ _(_{BoqComAu::Account.new(username: 'customer').login(password: nil)}.must_raise(ArgumentError).message).must_equal('password is missing.')
108
+ _(_{BoqComAu::Account.new.login(username: 'customer')}.must_raise(ArgumentError).message).must_equal('password is missing.')
109
+ end
110
+ end
111
+
95
112
  describe "#download_transactions" do
96
113
  def account_recording_steps
97
114
  account = account_with_driver(stand_in_driver)
@@ -112,6 +129,12 @@ describe BoqComAu::Account do
112
129
  account.download_transactions(account_number: '12345678', from_date: '2026-10-01', to_date: '2026-10-31')
113
130
  _(steps).must_equal([:get_transactions_page, :select_bank_account, [:enter_dates, '2026-10-01', '2026-10-31'], :search, :export_csv])
114
131
  end
132
+
133
+ it "names a missing account number, before going to the transactions page" do
134
+ account, steps = account_recording_steps
135
+ _(_{account.download_transactions(account_number: nil)}.must_raise(ArgumentError).message).must_equal('account_number is missing.')
136
+ _(steps).must_be_empty
137
+ end
115
138
  end
116
139
 
117
140
  describe "the browser" do
@@ -137,11 +160,18 @@ describe BoqComAu::Account do
137
160
  _{BoqComAu::Account.new(chrome_profile_directory: '~/profiles/boq')}.must_raise(ArgumentError)
138
161
  end
139
162
 
140
- it "logs in to BOQ, whatever else is passed to WebAccount" do
141
- account = BoqComAu::Account.new(headless: true, window_size: [1280, 800])
142
- _(account.send(:username_field_selector)).must_equal(BoqComAu::Account::PAGE_SELECTORS[:login_page_username_field_selector])
163
+ it "uses BOQ's selectors where none is given" do
164
+ account = BoqComAu::Account.new
165
+ _(account.send(:login_page_username_field_selector)).must_equal(BoqComAu::Account::PAGE_SELECTORS[:login_page_username_field_selector])
143
166
  _(account.send(:logout_button_selector)).must_equal(BoqComAu::Account::PAGE_SELECTORS[:logout_button_selector])
144
167
  end
168
+
169
+ it "logs in where told to, a keyword winning over BOQ's selector" do
170
+ account = BoqComAu::Account.new(login_page_url: 'https://test.example.com/logon', logout_button_selector: {id: 'logoff'})
171
+ _(account.send(:login_page_url)).must_equal('https://test.example.com/logon')
172
+ _(account.send(:logout_button_selector)).must_equal({id: 'logoff'})
173
+ _(account.send(:login_page_username_field_selector)).must_equal(BoqComAu::Account::PAGE_SELECTORS[:login_page_username_field_selector])
174
+ end
145
175
  end
146
176
 
147
177
  describe "#dates" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boq_com_au
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '0.7'
32
+ version: '0.8'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.7'
39
+ version: '0.8'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: minitest
42
42
  requirement: !ruby/object:Gem::Requirement