marty 2.4.0 → 2.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.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile.lock +1 -1
  3. data/app/components/marty/api_auth_view.rb +4 -27
  4. data/app/components/marty/extras/layout.rb +7 -1
  5. data/app/components/marty/grid.rb +10 -9
  6. data/app/controllers/marty/rpc_controller.rb +4 -2
  7. data/app/models/marty/api_auth.rb +1 -80
  8. data/app/models/marty/api_config.rb +4 -4
  9. data/app/models/marty/delorean_rule.rb +2 -3
  10. data/config/routes.rb +1 -1
  11. data/db/migrate/{501_add_api_class_to_marty_api_config.rb → 500_add_api_class_to_marty_api_config.rb} +0 -0
  12. data/lib/marty/aws/base.rb +98 -0
  13. data/lib/marty/util.rb +15 -0
  14. data/lib/marty/version.rb +1 -1
  15. data/other/marty/api/base.rb +3 -0
  16. data/spec/controllers/job_controller_spec.rb +1 -1
  17. data/spec/dummy/app/components/gemini/xyz_rule_view.rb +0 -1
  18. data/spec/dummy/config/application.rb +0 -1
  19. data/spec/features/enum_spec.rb +100 -35
  20. data/spec/features/log_view_spec.rb +5 -5
  21. data/spec/features/rule_spec.rb +30 -30
  22. data/spec/features/user_view_spec.rb +2 -0
  23. data/spec/lib/logger_spec.rb +1 -1
  24. data/spec/models/event_spec.rb +1 -1
  25. data/spec/models/promise_spec.rb +1 -1
  26. data/spec/models/user_spec.rb +6 -6
  27. data/spec/spec_helper.rb +9 -69
  28. data/spec/support/chromedriver.rb +41 -0
  29. data/spec/support/components/netzke_combobox.rb +57 -0
  30. data/spec/support/components/netzke_grid.rb +356 -0
  31. data/spec/support/custom_matchers.rb +18 -0
  32. data/spec/support/custom_selectors.rb +49 -0
  33. data/spec/support/delayed_job_helpers.rb +4 -5
  34. data/spec/support/download_helper.rb +52 -0
  35. data/spec/support/helper.rb +20 -0
  36. data/spec/support/netzke.rb +306 -0
  37. data/spec/support/performance_helper.rb +26 -0
  38. data/spec/support/post_run_logger.rb +32 -0
  39. data/spec/support/{spec_setup.rb → setup.rb} +19 -6
  40. data/spec/support/shared_connection.rb +31 -0
  41. data/spec/support/{clean_db_helpers.rb → shared_connection_db_helpers.rb} +2 -2
  42. data/spec/support/structure_compare.rb +62 -0
  43. data/spec/support/suite.rb +27 -0
  44. data/spec/support/{integration_helpers.rb → users.rb} +11 -9
  45. metadata +20 -8
  46. data/db/migrate/502_add_parameters_to_marty_api_auth.rb +0 -5
  47. data/spec/support/user_helpers.rb +0 -12
@@ -0,0 +1,26 @@
1
+ require Pathname.new(__FILE__).parent.to_s + '/post_run_logger'
2
+
3
+ module Marty; module RSpec; module PerformanceHelper
4
+ include Marty::RSpec::PostRunLogger
5
+
6
+ def calculate_baseline iterations
7
+ Benchmark.measure {
8
+ ActiveRecord::Base.uncached {(0...iterations).each { yield }}
9
+ }
10
+ end
11
+
12
+ def compare_baseline baseline, timings, opts={}
13
+ result_time = timings.map{|t| t.total}.sum
14
+ factor = result_time / baseline.total
15
+
16
+ lb = opts.delete(:lower_bound) || 1.5
17
+ ub = opts.delete(:upper_bound) || 5.0
18
+
19
+ post_run_log ' '+'-'*45,
20
+ " baseline: %.2f, result: %.2f, factor: %.2f" %
21
+ [baseline.total, result_time, factor],
22
+ ' '+'-'*45
23
+
24
+ expect(result_time).to be_between(baseline.total * lb, baseline.total * ub)
25
+ end
26
+ end end end
@@ -0,0 +1,32 @@
1
+ module Marty; module RSpec; module PostRunLogger
2
+ class Storage
3
+ def self.data
4
+ @@data ||= []
5
+ end
6
+
7
+ def self.test_number
8
+ @@num ||= 0
9
+ @@num += 1
10
+ end
11
+
12
+ def self.store_data(name, line)
13
+ data << " #{test_number}) #{name}"
14
+ data << Array(line).map { |string| " #{string}" }
15
+ data << ""
16
+ end
17
+
18
+ def self.dump_data
19
+ unless data.empty?
20
+ puts "\n\nPost Run Logging:\n\n"
21
+ puts data
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ def post_run_log(*log_string)
28
+ Storage.store_data example.example_group.parent_groups.map(&:description).
29
+ reverse.join(' ') + ' ' + example.description,
30
+ log_string
31
+ end
32
+ end end end
@@ -1,4 +1,9 @@
1
- module SpecSetup
1
+ module Marty; module RSpec; module Setup
2
+
3
+ def marty_whodunnit
4
+ Mcfly.whodunnit = Marty::User.find_by_login('marty')
5
+ end
6
+
2
7
  def load_scripts(path, dt)
3
8
  Marty::Script.load_scripts(path, dt)
4
9
  Marty::ScriptSet.clear_cache
@@ -13,11 +18,19 @@ module SpecSetup
13
18
  Marty::DataGrid.create_from_import(*args)
14
19
  end
15
20
 
16
- def marty_whodunnit
17
- Mcfly.whodunnit = Marty::User.find_by_login('marty')
18
- end
19
-
20
21
  def do_import_summary(*args)
21
22
  Marty::DataImporter.do_import_summary(*args)
22
23
  end
23
- end
24
+
25
+ def disable_triggers(table_name, &block)
26
+ begin
27
+ ActiveRecord::Base.connection.
28
+ execute("ALTER TABLE #{table_name} DISABLE TRIGGER USER;")
29
+
30
+ block.call
31
+ ensure
32
+ ActiveRecord::Base.connection.
33
+ execute("ALTER TABLE #{table_name} ENABLE TRIGGER USER;")
34
+ end
35
+ end
36
+ end end end
@@ -0,0 +1,31 @@
1
+ require Pathname.new(__FILE__).parent.to_s + '/shared_connection_db_helpers'
2
+
3
+ module Marty; module RSpec; module SharedConnection
4
+ @@classes_to_exclude_from_shared = ['Marty::Log']
5
+ mattr_accessor :classes_to_exclude_from_shared
6
+
7
+ EXCL_LAMBDA = lambda { classes_to_exclude_from_shared }.freeze
8
+
9
+ class ActiveRecord::Base
10
+ mattr_accessor :shared_connection
11
+ class << self
12
+ alias_method :orig_connection, :connection
13
+ end
14
+ def self.clear_connection
15
+ @@shared_connection = nil
16
+ end
17
+
18
+ clear_connection
19
+
20
+ def self.connection
21
+ EXCL_LAMBDA.call.include?(model_name) ? orig_connection :
22
+ @@shared_connection ||
23
+ ConnectionPool::Wrapper.new(:size => 1) {retrieve_connection}
24
+ end
25
+
26
+ def self.reset_shared_connection
27
+ @@shared_connection = ConnectionPool::Wrapper.
28
+ new(:size => 1) {retrieve_connection}
29
+ end
30
+ end
31
+ end end end
@@ -1,4 +1,4 @@
1
- module CleanDbHelpers
1
+ module Marty; module RSpec; module SharedConnectionDbHelpers
2
2
  def current_db
3
3
  ActiveRecord::Base.connection_config[:database]
4
4
  end
@@ -15,4 +15,4 @@ module CleanDbHelpers
15
15
  ActiveRecord::Base.reset_shared_connection
16
16
  self.use_transactional_tests = true
17
17
  end
18
- end
18
+ end end end
@@ -0,0 +1,62 @@
1
+ module Marty::RSpec::StructureCompare
2
+ def self.struct_compare_all(v1raw, v2raw, path=[], errs=[])
3
+ pathstr = path.map(&:to_s).join
4
+ v1,v2 = [v1raw, v2raw].map { |v| v.class == ActiveSupport::TimeWithZone ?
5
+ DateTime.parse(v.to_s) : v }
6
+
7
+ return errs + [v1["error"]] if
8
+ v1.class != v2.class && v1.class == Hash && v1["error"]
9
+
10
+ return errs + [v2["error"]] if
11
+ v1.class != v2.class && v2.class == Hash && v2["error"]
12
+
13
+ return errs + ["path=#{pathstr} class mismatch #{v1.class} #{v2.class}"] unless
14
+ v1.class == v2.class ||
15
+ [v1,v2].map(&:class).to_set == Set.new([Integer, Float])
16
+
17
+ case v1
18
+ when String
19
+ return errs + ["path=#{pathstr} #{v1} != #{v2}"] unless
20
+ v1 == v2 ||
21
+ Regexp.new('\A'+v1+'\z').match(v2) ||
22
+ Regexp.new('\A'+v2+'\z').match(v1)
23
+ when Integer, DateTime, TrueClass, FalseClass, NilClass
24
+ return errs + ["path=#{pathstr} #{v1} != #{v2}"] if v1 != v2
25
+ when Float
26
+ return errs + ["path=#{pathstr} #{v1} != #{v2}"] if v1.round(6) != v2.round(6)
27
+ when Hash
28
+ v1_v2, v2_v1 = v1.keys-v2.keys, v2.keys-v1.keys
29
+
30
+ errs.append("path=#{pathstr} hash extra keys #{v1_v2}") unless v1_v2.empty?
31
+ errs.append("path=#{pathstr} hash extra keys #{v2_v1}") unless v2_v1.empty?
32
+
33
+ return errs + v1.map do |childkey, childval|
34
+ struct_compare_all(childval, v2[childkey], path + [[childkey]], [])
35
+ end.flatten
36
+ when Array
37
+ errs.append("path=#{pathstr} array size mismatch #{v1.size} != #{v2.size}") if
38
+ v1.size != v2.size
39
+ return errs + v1.each_with_index.map do |childval,index|
40
+ struct_compare_all(childval, v2[index], path + [[index]], [])
41
+ end.flatten
42
+ else
43
+ raise "unhandled #{v1.class}"
44
+ end
45
+ errs
46
+ end
47
+ end
48
+
49
+ def struct_compare(v1raw, v2raw)
50
+ begin
51
+ res = Marty::RSpec::StructureCompare.struct_compare_all(v1raw, v2raw).first
52
+ rescue => e
53
+ e.message
54
+ end
55
+ end
56
+ def struct_compare_all(v1raw, v2raw)
57
+ begin
58
+ Marty::RSpec::StructureCompare.struct_compare_all(v1raw, v2raw)
59
+ rescue => e
60
+ e.message
61
+ end
62
+ end
@@ -0,0 +1,27 @@
1
+ relative = Pathname.new(__FILE__).parent.to_s
2
+ ['setup',
3
+ 'users',
4
+ 'components/netzke_combobox',
5
+ 'components/netzke_grid',
6
+ 'netzke',
7
+ 'download_helper',
8
+ 'chromedriver',
9
+ 'delayed_job_helpers',
10
+ 'post_run_logger',
11
+ 'helper',
12
+ 'performance_helper',
13
+ 'structure_compare',
14
+ 'custom_matchers',
15
+ 'custom_selectors',
16
+ ].each {|f| require (relative + '/' + f)}
17
+
18
+ module Marty; module RSpec; module Suite
19
+ include Marty::RSpec::Setup
20
+ include Marty::RSpec::Users
21
+ include Marty::RSpec::Netzke
22
+ include Marty::RSpec::DelayedJobHelpers
23
+ include Marty::RSpec::DownloadHelper
24
+ include Marty::RSpec::PostRunLogger
25
+ include Marty::RSpec::PerformanceHelper
26
+ include Marty::RSpec::StructureCompare
27
+ end end end
@@ -1,5 +1,4 @@
1
- module Marty::IntegrationHelpers
2
- # test setup helpers
1
+ module Marty; module RSpec; module Users
3
2
  def populate_test_users
4
3
  (1..2).each { |i|
5
4
  Rails.configuration.marty.roles.each { |role_name|
@@ -30,12 +29,15 @@ module Marty::IntegrationHelpers
30
29
  user.save
31
30
  end
32
31
 
33
- def log_in_as(username)
34
- Rails.configuration.marty.auth_source = 'local'
35
-
36
- ensure_on("/")
37
- log_in(username, Rails.configuration.marty.local_password)
38
- ensure_on("/")
32
+ def system_user
33
+ Marty::User.find_by_login('marty') # (system_login)
39
34
  end
40
35
 
41
- end
36
+ def create_user(name)
37
+ Marty::User.find_or_create_by!(login: name,
38
+ firstname: name,
39
+ lastname: 'test',
40
+ active: true)
41
+
42
+ end
43
+ end end end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marty
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Bostani
@@ -484,13 +484,13 @@ files:
484
484
  - db/migrate/400_create_dg_plv8_v1_fns.rb
485
485
  - db/migrate/410_jsonb_promise_result.rb
486
486
  - db/migrate/411_create_vw_promises.rb
487
- - db/migrate/501_add_api_class_to_marty_api_config.rb
488
- - db/migrate/502_add_parameters_to_marty_api_auth.rb
487
+ - db/migrate/500_add_api_class_to_marty_api_config.rb
489
488
  - db/seeds.rb
490
489
  - delorean/diagnostics.dl
491
490
  - delorean/script_report.dl
492
491
  - gemini_deprecations.md
493
492
  - lib/marty.rb
493
+ - lib/marty/aws/base.rb
494
494
  - lib/marty/content_handler.rb
495
495
  - lib/marty/data_change.rb
496
496
  - lib/marty/data_conversion.rb
@@ -1682,11 +1682,23 @@ files:
1682
1682
  - spec/other/diagnostic/reporter_spec.rb
1683
1683
  - spec/requests/routes_spec.rb
1684
1684
  - spec/spec_helper.rb
1685
- - spec/support/clean_db_helpers.rb
1685
+ - spec/support/chromedriver.rb
1686
+ - spec/support/components/netzke_combobox.rb
1687
+ - spec/support/components/netzke_grid.rb
1688
+ - spec/support/custom_matchers.rb
1689
+ - spec/support/custom_selectors.rb
1686
1690
  - spec/support/delayed_job_helpers.rb
1687
- - spec/support/integration_helpers.rb
1688
- - spec/support/spec_setup.rb
1689
- - spec/support/user_helpers.rb
1691
+ - spec/support/download_helper.rb
1692
+ - spec/support/helper.rb
1693
+ - spec/support/netzke.rb
1694
+ - spec/support/performance_helper.rb
1695
+ - spec/support/post_run_logger.rb
1696
+ - spec/support/setup.rb
1697
+ - spec/support/shared_connection.rb
1698
+ - spec/support/shared_connection_db_helpers.rb
1699
+ - spec/support/structure_compare.rb
1700
+ - spec/support/suite.rb
1701
+ - spec/support/users.rb
1690
1702
  homepage: https://github.com/arman000/marty
1691
1703
  licenses:
1692
1704
  - MIT
@@ -1707,7 +1719,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1707
1719
  version: '0'
1708
1720
  requirements: []
1709
1721
  rubyforge_project:
1710
- rubygems_version: 2.7.6
1722
+ rubygems_version: 2.6.14
1711
1723
  signing_key:
1712
1724
  specification_version: 4
1713
1725
  summary: A framework for working with versioned data
@@ -1,5 +0,0 @@
1
- class AddParametersToMartyApiAuth < ActiveRecord::Migration[5.1]
2
- def change
3
- add_column :marty_api_auths, :parameters, :jsonb, default: {}
4
- end
5
- end
@@ -1,12 +0,0 @@
1
- module UserHelpers
2
- def self.system_user
3
- Marty::User.find_by_login('marty') # (system_login)
4
- end
5
-
6
- def self.create_user(name)
7
- Marty::User.find_or_create_by!(login: name,
8
- firstname: name,
9
- lastname: 'test',
10
- active: true)
11
- end
12
- end