yui_rest_client 0.5.0
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/.github/workflows/publish.yml +33 -0
- data/.github/workflows/test.yml +26 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.rubocop.yml +41 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +216 -0
- data/Rakefile +20 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/yui_rest_client.rb +42 -0
- data/lib/yui_rest_client/actions.rb +12 -0
- data/lib/yui_rest_client/app.rb +230 -0
- data/lib/yui_rest_client/error.rb +13 -0
- data/lib/yui_rest_client/filter_extractor.rb +28 -0
- data/lib/yui_rest_client/http/http_client.rb +36 -0
- data/lib/yui_rest_client/http/response.rb +21 -0
- data/lib/yui_rest_client/http/version_controller.rb +26 -0
- data/lib/yui_rest_client/http/widget_controller.rb +54 -0
- data/lib/yui_rest_client/local_process.rb +73 -0
- data/lib/yui_rest_client/logger.rb +32 -0
- data/lib/yui_rest_client/timer.rb +20 -0
- data/lib/yui_rest_client/version.rb +6 -0
- data/lib/yui_rest_client/wait.rb +21 -0
- data/lib/yui_rest_client/waitable.rb +39 -0
- data/lib/yui_rest_client/widgets.rb +30 -0
- data/lib/yui_rest_client/widgets/bargraph.rb +62 -0
- data/lib/yui_rest_client/widgets/base.rb +114 -0
- data/lib/yui_rest_client/widgets/button.rb +33 -0
- data/lib/yui_rest_client/widgets/checkbox.rb +53 -0
- data/lib/yui_rest_client/widgets/combobox.rb +95 -0
- data/lib/yui_rest_client/widgets/datefield.rb +47 -0
- data/lib/yui_rest_client/widgets/label.rb +41 -0
- data/lib/yui_rest_client/widgets/menubutton.rb +48 -0
- data/lib/yui_rest_client/widgets/multilinebox.rb +84 -0
- data/lib/yui_rest_client/widgets/numberbox.rb +76 -0
- data/lib/yui_rest_client/widgets/progressbar.rb +45 -0
- data/lib/yui_rest_client/widgets/radiobutton.rb +35 -0
- data/lib/yui_rest_client/widgets/richtext.rb +36 -0
- data/lib/yui_rest_client/widgets/selectionbox.rb +87 -0
- data/lib/yui_rest_client/widgets/tab.rb +81 -0
- data/lib/yui_rest_client/widgets/table.rb +154 -0
- data/lib/yui_rest_client/widgets/textbox.rb +94 -0
- data/lib/yui_rest_client/widgets/timefield.rb +45 -0
- data/lib/yui_rest_client/widgets/tree.rb +149 -0
- data/yui_rest_client.gemspec +38 -0
- metadata +222 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ea981c5b7efbf645df05748af02a42230510892162b5279634794d527d82ddbc
|
4
|
+
data.tar.gz: e3291d947be7d5e0d1d1257766fb4de0ccaf91891c4f53e7b049a05a90596a5d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2aa47e95d61d4f9e4a6b7a02e81e55af1274c9d93c73bcc5f3856c6389083f482c7cd5fe125a65b0b2061704896f60777542b487a7d3ce24d5a59f69bb58f8ea
|
7
|
+
data.tar.gz: 2307d790e8d50ba3abf495d055f283b2ba778b3b9e1655712e0d59d00ddbe0793e41d08bcda5ba52076645e2f46207545f9c624f79e94f4f6521280e3676713c
|
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
name: Publish Gem
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.5
|
16
|
+
- name: Install dependencies
|
17
|
+
run: bundle install
|
18
|
+
- name: Setup credentials
|
19
|
+
env:
|
20
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
21
|
+
run: |
|
22
|
+
cat << EOF > ~/.gem/credentials
|
23
|
+
---
|
24
|
+
:rubygems_api_key: $RUBYGEMS_API_KEY
|
25
|
+
EOF
|
26
|
+
chmod 0600 ~/.gem/credentials
|
27
|
+
- name: Build gem
|
28
|
+
run: gem build yui_rest_client.gemspec
|
29
|
+
- name: Push gem
|
30
|
+
run: gem push yui_rest_client*.gem
|
31
|
+
- name: Cleanup credentials
|
32
|
+
if: always()
|
33
|
+
run: rm ~/.gem/credentials
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: pull_request
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [ '2.5', '2.6' ]
|
11
|
+
name: Ruby ${{ matrix.ruby }}
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Check version file was changed
|
15
|
+
run: |
|
16
|
+
git fetch origin master
|
17
|
+
git --no-pager diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD master` | grep version.rb
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
- name: Install dependencies
|
22
|
+
run: bundle install
|
23
|
+
- name: Run rubocop
|
24
|
+
run: bundle exec rubocop
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rspec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Cops documentation: https://rubocop.readthedocs.io/en/stable/
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
|
6
|
+
Layout/LineLength:
|
7
|
+
Max: 120
|
8
|
+
|
9
|
+
Layout/SpaceAroundMethodCallOperator:
|
10
|
+
Enabled: true
|
11
|
+
|
12
|
+
Lint/RaiseException:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Lint/StructNewOverride:
|
16
|
+
Enabled: true
|
17
|
+
|
18
|
+
Lint/UriEscapeUnescape:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Metrics/BlockLength:
|
22
|
+
Exclude:
|
23
|
+
- "**/*_spec.rb"
|
24
|
+
|
25
|
+
Style/Documentation:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/ExponentialNotation:
|
29
|
+
Enabled: true
|
30
|
+
|
31
|
+
Style/HashEachMethods:
|
32
|
+
Enabled: true
|
33
|
+
|
34
|
+
Style/HashTransformKeys:
|
35
|
+
Enabled: true
|
36
|
+
|
37
|
+
Style/HashTransformValues:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
Metrics/ModuleLength:
|
41
|
+
Max: 500
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019-2020 SUSE LLC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
# YuiRestClient
|
2
|
+
|
3
|
+
Ruby gem to interact with YaST applications via libyui-rest-api.
|
4
|
+
See documentation of the [libyui-rest-api project](https://github.com/libyui/libyui-rest-api/)
|
5
|
+
for more details about server side implementation.
|
6
|
+
|
7
|
+
Usage example:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
require 'yui_rest_client'
|
11
|
+
|
12
|
+
app = YuiRestClient::App.new(host: 'localhost', port: '9999')
|
13
|
+
button = app.button(id: 'settime')
|
14
|
+
button.click
|
15
|
+
```
|
16
|
+
|
17
|
+
## Installing yui_rest_client
|
18
|
+
|
19
|
+
As soon as the gem is in development, run the following command from command line:
|
20
|
+
|
21
|
+
```
|
22
|
+
gem install yui_rest_client
|
23
|
+
```
|
24
|
+
|
25
|
+
In order to build and install locally run:
|
26
|
+
```
|
27
|
+
gem build yui_rest_client.gemspec
|
28
|
+
gem install yui_rest_client-*.gem
|
29
|
+
```
|
30
|
+
|
31
|
+
Now need to require gem in order to use it.
|
32
|
+
|
33
|
+
## Initialize the app under control
|
34
|
+
|
35
|
+
It is assumed the application is running on `localhost:9999`.
|
36
|
+
Then the code to initialize the application looks like:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'yui_rest_client'
|
40
|
+
|
41
|
+
app = YuiRestClient::App.new(host: 'localhost', port: '9999')
|
42
|
+
```
|
43
|
+
|
44
|
+
## Supported widgets
|
45
|
+
|
46
|
+
yui_rest_client supports different types of widgets.
|
47
|
+
|
48
|
+
Here are examples of usage:
|
49
|
+
|
50
|
+
### Button
|
51
|
+
```ruby
|
52
|
+
app.button(id: 'test_id').click # clicks the button with id 'test_id'
|
53
|
+
app.button(label: 'test_label').debug_label # get 'debug_label' value with label 'test_label'
|
54
|
+
```
|
55
|
+
|
56
|
+
### Bargraph
|
57
|
+
```ruby
|
58
|
+
# Get list of labels in the segments:
|
59
|
+
app.bargraph(class: YBarGraph).labels
|
60
|
+
# Get array of hashes containing label->value pairs denoting each segment:
|
61
|
+
app.bargraph(class: YBarGraph).segments
|
62
|
+
# Get list of values in the segments:
|
63
|
+
app.bargraph(class: YBarGraph).values
|
64
|
+
```
|
65
|
+
|
66
|
+
### Checkbox
|
67
|
+
```ruby
|
68
|
+
app.checkbox(id: 'test_id').check # checks the checkbox with id 'test_id'
|
69
|
+
app.checkbox(label: 'test_label', class: 'YCheckBox').checked? # gets the state of checkbox with label 'test_label'
|
70
|
+
app.checkbox(id: 'test_id').toggle # toggles the checkbox with id 'test_id'
|
71
|
+
app.checkbox(label: 'test_label', class: 'YCheckBoxFrame').uncheck # unchecks the checkbox with id 'test_id'
|
72
|
+
```
|
73
|
+
|
74
|
+
### Combobox
|
75
|
+
```ruby
|
76
|
+
app.combobox(id: 'test_id').items # gets all available items for combobox with id 'test_id'
|
77
|
+
app.combobox(id: 'test_id').select # selects the checkbox with id 'test_id'
|
78
|
+
app.combobox(id: 'test_id').selected_item # gets the selected item in combobox with id 'test_id'
|
79
|
+
app.combobox(label: 'cmbx', class: 'YComboBox').set # Sets custom string to the editable checkbox
|
80
|
+
```
|
81
|
+
|
82
|
+
### Datefield
|
83
|
+
```ruby
|
84
|
+
# Set date field to 2048-08-16
|
85
|
+
app.datefield(class: 'YDateField').set(Date.new(2048, 8, 16))
|
86
|
+
app.datefield(id: 'date').value # gets value from datefield with id 'date'
|
87
|
+
```
|
88
|
+
|
89
|
+
### Label
|
90
|
+
```ruby
|
91
|
+
app.label(id: 'test_id').heading? # gets if label has bold font respresentation with id 'test_id'
|
92
|
+
app.label(id: 'test_id').text # gets text from label with id 'test_id'
|
93
|
+
```
|
94
|
+
|
95
|
+
### Menubutton
|
96
|
+
```ruby
|
97
|
+
app.menubutton(id: 'test_id').click('button1') # clicks on 'button1' of menubutton with id 'test_id'
|
98
|
+
```
|
99
|
+
|
100
|
+
### Numberbox
|
101
|
+
```ruby
|
102
|
+
app.numberbox(id: 'test_id').min_value # gets min value to be set in numberbox with id 'test_id'
|
103
|
+
app.numberbox(id: 'test_id').max_value # gets max value to be set in numberbox with id 'test_id'
|
104
|
+
app.numberbox(id: 'test_id').set(99) # sets 99 to numberbox with id 'test_id'
|
105
|
+
app.numberbox(id: 'test_id').value # gets value from numberbox with id 'test_id'
|
106
|
+
```
|
107
|
+
|
108
|
+
### Radiobutton
|
109
|
+
```ruby
|
110
|
+
app.radiobutton(id: 'test_id').select # selects the radiobutton with id 'test_id'
|
111
|
+
app.radiobutton(id: 'test_id').selected? # gets the state of radiobutton with id 'test_id'
|
112
|
+
```
|
113
|
+
|
114
|
+
### Richtext
|
115
|
+
```ruby
|
116
|
+
app.richtext(id: 'test_id').click_link('test_link') # clicks on link "test_link" with id 'test_id'
|
117
|
+
app.richtext(id: 'test_id').text # gets text from richtext
|
118
|
+
```
|
119
|
+
|
120
|
+
### Tab
|
121
|
+
```ruby
|
122
|
+
app.tab(id: 'test_id').items # gets items from tab with id 'test_id'
|
123
|
+
app.tab(id: 'test_id').select(value: 'item') # selects specific tab with id 'test_id'
|
124
|
+
app.tab(id: 'test_id').selected_item # gets selected tab for tab with id 'test_id'
|
125
|
+
```
|
126
|
+
|
127
|
+
### Table
|
128
|
+
```ruby
|
129
|
+
# checks if there is not rows in table with id 'test_id':
|
130
|
+
app.table(id: 'test_id').empty?
|
131
|
+
# gets rows in the table with id 'test_id':
|
132
|
+
app.table(id: 'test_id').items
|
133
|
+
# selects row in table with value test.item.1 and column test.header:
|
134
|
+
app.table(id: 'test_id').select( value: 'test.item.1', column: 'test.header' )
|
135
|
+
# selects row with number 3, numeration starts from 0 and corresponds to the order
|
136
|
+
# in the list returned by method `items`:
|
137
|
+
app.table(id: 'test_id').select(row: 3)
|
138
|
+
# gets items currently selected in table with id 'test_id':
|
139
|
+
app.table(id: 'test_id').seleted_items
|
140
|
+
|
141
|
+
|
142
|
+
```
|
143
|
+
### Textbox
|
144
|
+
```ruby
|
145
|
+
app.textbox(id: 'test_id').max_length
|
146
|
+
app.textbox(id: 'test_id').set('Test Text') # sets "Test Text" to textbox with id 'test_id'
|
147
|
+
app.textbox(id: 'test_id').password? # checks password mode for textbox with id 'test_id'
|
148
|
+
app.textbox(id: 'test_id').valid_chars # checks valid chars for textbox with id 'test_id'
|
149
|
+
app.textbox(id: 'test_id').value # gets value from textbox with id 'test_id'
|
150
|
+
```
|
151
|
+
|
152
|
+
### TimeField
|
153
|
+
```ruby
|
154
|
+
# Set TimeField to current time
|
155
|
+
app.timefield(label: 'time', class: 'YTimeField').set(Time.now)
|
156
|
+
app.timefield(id: 'time').value # gets value from timefield with id 'time'
|
157
|
+
```
|
158
|
+
|
159
|
+
### Tree
|
160
|
+
```ruby
|
161
|
+
app.tree(id: 'test_id').items # gets items from tree with id 'test_id'
|
162
|
+
app.tree(id: 'test_id').select('node1|node1_2') # selects item in tree with id 'test_id'
|
163
|
+
app.tree(id: 'test_id').selected_item # gets currently highlighted item from tree with id 'test_id'
|
164
|
+
```
|
165
|
+
|
166
|
+
## Filters
|
167
|
+
|
168
|
+
yui_rest_client supports the same filters, as libyui-rest-api provides:
|
169
|
+
|
170
|
+
* id - widget ID serialized as string, might include special characters like backtick (\`)
|
171
|
+
* label - widget label as currently displayed (i.e. translated!)
|
172
|
+
* class - widget class
|
173
|
+
|
174
|
+
Also, regex for the filters is allowed.
|
175
|
+
|
176
|
+
Example:
|
177
|
+
```ruby
|
178
|
+
app.button(id: /.*test/).debug_label
|
179
|
+
```
|
180
|
+
|
181
|
+
## Waits
|
182
|
+
|
183
|
+
### Default timeout and interval
|
184
|
+
|
185
|
+
All the actions against widgets in yui_rest_client are made with default timeout and interval.
|
186
|
+
Default timeout is 5 sec, default interval is 0.5 sec.
|
187
|
+
That means yui_rest_client will repeat sending requests to YaST application every 0.5 seconds until 5 seconds
|
188
|
+
timeout will be reached. This default wait is needed because widgets may not be loaded immediately while trying to
|
189
|
+
interact with them (e.g. when navigating from one screen to another).
|
190
|
+
|
191
|
+
The default timeout and interval can be changed by the following:
|
192
|
+
|
193
|
+
```ruby
|
194
|
+
YuiRestClient.timeout = 10
|
195
|
+
YuiRestClient.interval = 1
|
196
|
+
```
|
197
|
+
|
198
|
+
### Specific waits
|
199
|
+
|
200
|
+
All the widgets include Waitable module, which contains special methods to allow explicit waiting:
|
201
|
+
`wait_until` and `wait_while`.
|
202
|
+
These methods can be used when it is needed to wait until some property of the widget will be changed.
|
203
|
+
|
204
|
+
For example, wait until button will be enabled and click on it:
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
# with #to_proc syntax:
|
208
|
+
app.button(id: 'test_id').wait_until(&:enabled?).click
|
209
|
+
|
210
|
+
# without #to_proc syntax:
|
211
|
+
app.button(id: 'test_id').wait_until{ |button| button.enabled? }.click
|
212
|
+
```
|
213
|
+
|
214
|
+
## License
|
215
|
+
|
216
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task default: :spec
|
9
|
+
|
10
|
+
task :integration do
|
11
|
+
RSpec::Core::RakeTask.new(:integration) do |t|
|
12
|
+
t.pattern = 'spec/widgets/*_spec.rb'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
task :unit do
|
17
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
18
|
+
t.pattern = 'spec/unit/**/*_spec.rb'
|
19
|
+
end
|
20
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'yui_rest_client'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'json'
|
5
|
+
require 'net/http'
|
6
|
+
require 'uri'
|
7
|
+
require 'timeout'
|
8
|
+
require 'time'
|
9
|
+
|
10
|
+
require 'yui_rest_client/version'
|
11
|
+
require 'yui_rest_client/local_process'
|
12
|
+
require 'yui_rest_client/widgets'
|
13
|
+
require 'yui_rest_client/logger'
|
14
|
+
require 'yui_rest_client/timer'
|
15
|
+
require 'yui_rest_client/wait'
|
16
|
+
require 'yui_rest_client/app'
|
17
|
+
require 'yui_rest_client/http/http_client'
|
18
|
+
require 'yui_rest_client/http/response'
|
19
|
+
require 'yui_rest_client/http/version_controller'
|
20
|
+
require 'yui_rest_client/http/widget_controller'
|
21
|
+
require 'yui_rest_client/error'
|
22
|
+
require 'yui_rest_client/actions'
|
23
|
+
require 'yui_rest_client/filter_extractor'
|
24
|
+
|
25
|
+
# Client to interact with YAST UI rest api framework for integration testing
|
26
|
+
module YuiRestClient
|
27
|
+
class << self
|
28
|
+
attr_writer :timeout, :interval
|
29
|
+
|
30
|
+
def timeout
|
31
|
+
@timeout ||= 5
|
32
|
+
end
|
33
|
+
|
34
|
+
def interval
|
35
|
+
@interval ||= 0.5
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.logger
|
40
|
+
@logger ||= YuiRestClient::Logger.new
|
41
|
+
end
|
42
|
+
end
|