testdata 1.1.10 → 1.1.11

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: 538ee4e9da6112785d2a5adb42574122aac61b61132b737b8a514acaad5978e9
4
- data.tar.gz: 335a22cee75aa3760bd10dbf3bb3d814aafbe320f0bd4f7f1b721136743b26d6
3
+ metadata.gz: a4d71c51315a66e4f97f335ede3ec7aa5cf69fbe8493eb33864b63b89a9ba5c2
4
+ data.tar.gz: bb8a6a638e834b42851fd7e8ad926693ec87a9f2e096bb42a28f97592fcd2436
5
5
  SHA512:
6
- metadata.gz: 5b4ead3de090642fc503b1d1a076e2632678962adf4f3a0f0e972c7b33c10965f4de040c1d9c65cf3ae54a0e194c7f557cd9a27dada6d069744f1ea6956469d4
7
- data.tar.gz: e6784581fdfcfe104897f800d1866ed10375cc9425408a20d7eed146ea1775a301a558a803b229b267c5fc689367dc3ad9fe6c198a04fd5f90fa462bf462727f
6
+ metadata.gz: 3709ed12d265d209aa48bc4d7bccc0ce2dd5d346cb214a133268d84c2b418552b1f3ee0afce99e0aff19ba5123b421fb06d36e4ac53ab91f5e01510ab5539bf2
7
+ data.tar.gz: 3b7efa449c561e00be89edc388e8b3f5b0294c95a33c261dd04fd7f873a4b56319c277677bb2af2222ce1720c76eac66a943378afb8086996e09f5f962784882
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/testdata.rb CHANGED
@@ -13,7 +13,7 @@ class TestdataException < Exception
13
13
  end
14
14
 
15
15
  module Testdata
16
-
16
+
17
17
  class Base
18
18
  using ColouredText
19
19
 
@@ -22,7 +22,7 @@ module Testdata
22
22
  attr_accessor :debug
23
23
 
24
24
  def initialize(s, options={})
25
-
25
+
26
26
  super()
27
27
 
28
28
  @params = {}
@@ -33,14 +33,14 @@ module Testdata
33
33
  # open the testdata document
34
34
  procs = {
35
35
  String: proc {|x|
36
-
36
+
37
37
  if x.strip[/^</] then
38
38
  x
39
39
  elsif x[/https?:\/\//] then
40
40
  read_url x
41
41
  else
42
42
  read_file x
43
- end
43
+ end
44
44
  },
45
45
  Polyrex: proc {|x| x.to_xml}
46
46
  }
@@ -48,26 +48,26 @@ module Testdata
48
48
  buffer = procs[s.class.to_s.to_sym].call(s)
49
49
 
50
50
  @doc = Rexle.new(buffer)
51
-
51
+
52
52
  o = {log: false}.merge(options)
53
53
 
54
54
  @log = o[:log] == true ? Rexle.new(tests) : nil
55
55
  end
56
56
 
57
57
  def run(raw_x=nil, debug2=nil)
58
-
58
+
59
59
  # verify the document has unique path numbers
60
-
60
+
61
61
  a = @doc.root.xpath('records/test/summary/path/text()')
62
62
  duplicates = a.select{ |e| a.count(e) > 1 }.uniq
63
-
63
+
64
64
  if duplicates.any? then
65
- raise 'Duplicate path found. Path: ' + duplicates.inspect
65
+ raise 'Duplicate path found. Path: ' + duplicates.inspect
66
66
  end
67
67
 
68
68
  @debug2 = debug2 ? true : false
69
69
  @success = []
70
-
70
+
71
71
  x = if raw_x and raw_x[/\d+\.\.\d+/] then
72
72
  x, y = raw_x.split('..').map(&:to_i)
73
73
  id = Range.new(x,y)
@@ -75,15 +75,15 @@ module Testdata
75
75
  raw_x
76
76
  end
77
77
 
78
- procs = {NilClass: :test_all, Range: :test_range, String: :test_id,
78
+ procs = {NilClass: :test_all, Range: :test_range, String: :test_id,
79
79
  Integer: :test_id, Fixnum: :test_id}
80
80
 
81
81
  method(procs[x.class.to_s.to_sym]).call(x)
82
82
  summary()
83
83
  end
84
-
84
+
85
85
  private
86
-
86
+
87
87
  def testdata_values(id)
88
88
 
89
89
  node = @doc.root.element "records/test[summary/path='#{id}']"
@@ -91,7 +91,7 @@ module Testdata
91
91
 
92
92
  path_no = node.text('summary/path')
93
93
 
94
- input_summary = node.element 'records/input/summary'
94
+ input_summary = node.element 'records/input/summary'
95
95
  input_summary.delete 'schema | format_mask | recordx_type'
96
96
 
97
97
  input_nodes = input_summary.xpath('*') #[1..-1]
@@ -105,8 +105,8 @@ module Testdata
105
105
 
106
106
  type, desc = summary.text('type'), summary.text('description')
107
107
 
108
- output_summary = node.element 'records/output/summary'
109
- output_summary.delete 'schema | format_mask | recordx_type'
108
+ output_summary = node.element 'records/output/summary'
109
+ output_summary.delete 'schema | format_mask | recordx_type'
110
110
 
111
111
  output_nodes = output_summary.xpath('*') #[1..-1]
112
112
  output_values = output_nodes.map{|x| x.texts.map(&:unescape).join.strip}
@@ -119,32 +119,32 @@ module Testdata
119
119
  x ||=(0..-1)
120
120
 
121
121
  break_on_fail = @doc.root.element('summary/break_on_fail/text()') == 'true'
122
-
122
+
123
123
  test_id = nil
124
124
 
125
125
  begin
126
-
126
+
127
127
  @doc.root.xpath("records/test/summary/path/text()")[x].each do |id|
128
-
128
+
129
129
  test_id = id
130
130
  puts 'testing id: ' + id.inspect
131
131
  result = test_id(id)
132
- break if result == false and break_on_fail
133
-
132
+ break if result == false and break_on_fail
133
+
134
134
  end
135
-
135
+
136
136
  rescue
137
137
 
138
138
  @success << [false, test_id.to_i]
139
139
  end
140
-
140
+
141
141
 
142
142
  end
143
143
 
144
144
  def test_id(id='')
145
145
 
146
146
 
147
- path_no, inputs, input_names, type, expected, @desc =
147
+ path_no, inputs, input_names, type, expected, @desc =
148
148
  testdata_values(id.to_s)
149
149
  @inputs = inputs
150
150
 
@@ -154,7 +154,7 @@ module Testdata
154
154
  puts "warning: no test route found for " + type unless raw_actual
155
155
 
156
156
  result = nil
157
- @success << [nil, path_no.to_i]
157
+ @success << [nil, path_no.to_i]
158
158
 
159
159
  begin
160
160
 
@@ -164,7 +164,7 @@ module Testdata
164
164
  b = expected.map(&:strip)
165
165
 
166
166
  if @debug == true or @debug2 == true then
167
-
167
+
168
168
  inputs = input_names.zip(inputs).map{|x| ' ' + x.join(": ")}\
169
169
  .join("\n")
170
170
 
@@ -176,18 +176,18 @@ module Testdata
176
176
 
177
177
  result = a.join.force_encoding("UTF-8") == \
178
178
  b.join.force_encoding("UTF-8")
179
-
179
+
180
180
  if (@debug == true or @debug2 == true) and result == false then
181
181
 
182
182
  # diff the expected and actual valuess
183
183
  puts DiffyC32.new(b.first, a.first).to_s
184
-
184
+
185
185
  end
186
186
  else
187
187
  result = [raw_actual].compact == expected
188
188
  end
189
189
 
190
- rescue Exception => e
190
+ rescue Exception => e
191
191
  err_label = e.message + " :: \n" + e.backtrace.join("\n")
192
192
  raise TestdataException, err_label
193
193
  result = false
@@ -198,15 +198,15 @@ module Testdata
198
198
  end
199
199
 
200
200
  def test_range(range)
201
-
201
+
202
202
  a = @doc.root.xpath("records/test/summary/path/text()")
203
203
  a[range].each {|x| test_id x}
204
204
  end
205
-
205
+
206
206
  def tests(*args)
207
207
  # override this method in the child class
208
208
  end
209
-
209
+
210
210
  def read_rdx(buffer)
211
211
  puts 'inside read_rdf: buffer: ' + buffer.inspect
212
212
  dx = Dynarex.new
@@ -232,7 +232,7 @@ module Testdata
232
232
  dx.all.each.with_index do |x, i|
233
233
 
234
234
  px.create.test(path: (i+1).to_s, type: dx.test_type) do |create|
235
-
235
+
236
236
  raw_inputs.each do |fld_in|
237
237
 
238
238
  create.input(fld_in[0..-4].to_sym => \
@@ -248,17 +248,17 @@ module Testdata
248
248
  end
249
249
 
250
250
  px.to_xml
251
-
251
+
252
252
  end
253
253
 
254
- def read_file(s)
254
+ def read_file(s)
255
255
  buffer = File.open(s, 'r').read
256
256
  ext = s[/\.(\w+)$/,1]
257
- method(('read_' + ext).to_sym).call(buffer)
257
+ method(('read_' + ext).to_sym).call(buffer)
258
258
  end
259
-
259
+
260
260
  def read_url(url)
261
- buffer = open(url, 'UserAgent' => 'Testdata').read
261
+ buffer = URI.open(url, 'UserAgent' => 'Testdata').read
262
262
  ext = url[/.*\/[^\.]+\.(\w+)/,1]
263
263
  method(('read_' + ext).to_sym).call(buffer)
264
264
  end
@@ -266,7 +266,7 @@ module Testdata
266
266
  def read_xml(buffer)
267
267
  buffer
268
268
  end
269
-
269
+
270
270
  def read_td(buffer)
271
271
  puts 'buffer: ' + buffer
272
272
  TestdataText.parse buffer
@@ -285,73 +285,73 @@ module Testdata
285
285
  score: [success.grep(true), success].map(&:length).join('/'),
286
286
  failed: @success.select{|x| x[0] == false}.map(&:last).sort
287
287
  }
288
-
288
+
289
289
  def h.to_s()
290
290
  passed = self[:passed] ? self[:passed].to_s.light_green : self[:passed].to_s.light_red
291
- "{passed: #{passed}, score: #{self[:score]}, failed: #{self[:failed]}}"
292
-
291
+ "{passed: #{passed}, score: #{self[:score]}, failed: #{self[:failed]}}"
292
+
293
293
  end
294
-
294
+
295
295
  h
296
296
  end
297
297
  end
298
298
 
299
299
  class Unit
300
-
300
+
301
301
  attr_reader :to_s
302
302
 
303
303
  def initialize(s)
304
-
304
+
305
305
  super()
306
306
  @a = []
307
-
307
+
308
308
  buffer, _ = RXFHelper.read(s)
309
309
 
310
310
  @doc = Rexle.new(buffer)
311
311
 
312
312
  @doc.root.xpath('records/test').map do |test|
313
-
314
- path, type, description = test.xpath('summary/*/text()')
315
- records = test.element('records')
316
-
313
+
314
+ path, type, description = test.xpath('summary/*/text()')
315
+ records = test.element('records')
316
+
317
317
  inputs = records.xpath('input/summary/*').map\
318
318
  {|x| [x.name, x.texts.join.strip]}
319
319
 
320
320
  outputs = records.xpath('output/summary/*').map\
321
321
  {|x| [x.name, x.texts.join.strip]}
322
-
322
+
323
323
  @a << {type: type, in: inputs, out: outputs}
324
-
324
+
325
325
  end
326
-
326
+
327
327
  end # end of initialize()
328
-
328
+
329
329
  def to_s()
330
330
  =begin
331
331
  s = %Q(
332
332
  require_relative "#{testgem}"
333
333
  require "test/unit"
334
-
334
+
335
335
  class #{testclass} < Test::Unit::TestCase
336
-
336
+
337
337
  def #{types[i]}
338
338
  #{@lines.join("\n ")}
339
339
  end
340
-
340
+
341
341
  end
342
342
  )
343
343
  =end
344
344
  #read the .rsf file
345
345
  script = @doc.root.element('summary/script/text()')
346
346
  raise 'script XML entry not found' unless script
347
-
347
+
348
348
  if script then
349
- filename = script[/[\/]+\.rsf$/]
349
+ filename = script[/[\/]+\.rsf$/]
350
350
  buffer, _ = RXFHelper.read(filename)
351
351
  end
352
352
  #@a.group_by {|x| x[:type]}
353
-
354
-
353
+
354
+
355
355
  end
356
356
  end
357
357
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.10
4
+ version: 1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkxMDA3MDk0MTU2WhcN
15
- MjAxMDA2MDk0MTU2WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC2E/7O
17
- uQtSwiOjY7M3mU5cZOQeF3mNUXsYF9Sg37oHlh9a960rQ86X/JTNjw/H9GpMwxQA
18
- bZCEElZUfMFTCQmxK46elKkhd1q4A1vClsYNKGwT85yO619Mqq7W7RzqsyuMN6AC
19
- EvtUXz3FJ9hXtacFEXdUNMu7zuV+GMfeOXZlsORKGsI5GR9XPQ0GquyZr8sdOJh0
20
- ijFDX+MPg3R2Px1NHu/iYZZeh/AHmdce4tTbQpqIE+wlc66P2NjOOZ6y3Yc2V/Mc
21
- XfbQMq02FXwVVX60bTzh6KFvrYifsLQvGdW4TEY0+JOAyTUIO/WxwYDTJ+6suES7
22
- r9sUEKxzJ6EHmPj3olz+86PwsOySY073euOXA3afBTvYkaVm2WVzUjBTz35+F7pv
23
- Ov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QoaJh/6LKnoDWkhrVwSuRJtD8qpOS/wjKqqscZlxS9m/
33
+ +61VC+IRSjjSHUZUzBHmRsONgYITuw8psX60aEc4oi4SOJuQLunsARvYDY+NO5S0
34
+ q8Xb225jZx4fdmDXd/EiMLn3hjva85JsJVfrE7eS0dPhZTNv36auPeHGMUEBDKmz
35
+ VPCX5Cuw6OER1XAXBrbU+Yxtynmu52uURikgRGv3kNN7uFNP2ObtG4bePdjcyRyF
36
+ ZoODyxvFiUzKN1ar4bIjsI+l
37
37
  -----END CERTIFICATE-----
38
- date: 2020-09-18 00:00:00.000000000 Z
38
+ date: 2021-11-18 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: app-routes
@@ -106,7 +106,7 @@ dependencies:
106
106
  version: '1.3'
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 1.3.1
109
+ version: 1.3.4
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
@@ -116,9 +116,9 @@ dependencies:
116
116
  version: '1.3'
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 1.3.1
119
+ version: 1.3.4
120
120
  description:
121
- email: james@jamesrobertson.eu
121
+ email: digital.robertson@gmail.com
122
122
  executables: []
123
123
  extensions: []
124
124
  extra_rdoc_files: []
@@ -143,7 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.0.3
146
+ rubyforge_project:
147
+ rubygems_version: 2.7.10
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: A test framework which accepts test data in a Polyrex format.
metadata.gz.sig CHANGED
Binary file