Blame view

test/query_test.rb 1.76 KB
dc8aa5b6   Joe Weakley   Rubocop corrections
1
2
3
  # frozen_string_literal: true
  
  require 'test_helper'
96149efa   Isaac Lewis   working query browse
4
5
  
  class QueryTest < Minitest::Test
f65bf747   Joe Weakley   Added and configu...
6
7
8
9
    extend Minitest::Spec::DSL
    before { VCR.insert_cassette name }
    after { VCR.eject_cassette }
  
23108441   Nathan Ockerman   Replace sensitive...
10
11
12
    let(:username) { ENV['SYSPRO_USERNAME'] }
    let(:password) { ENV['SYSPRO_PASSWORD'] }
    let(:company) { ENV['SYSPRO_COMPANY'] }
f65bf747   Joe Weakley   Added and configu...
13
    let(:company_password) { '' }
23108441   Nathan Ockerman   Replace sensitive...
14
  
f65bf747   Joe Weakley   Added and configu...
15
16
17
    let(:user_id) do
      Syspro::Logon.logon(username, password, company, company_password)
    end
96149efa   Isaac Lewis   working query browse
18
  
f65bf747   Joe Weakley   Added and configu...
19
    def test_query_browse # rubocop:disable Metrics/MethodLength
701afa86   Samuel J Clopton   Move configuratio...
20
      skip 'A new VCR cassette needs recorded for this test to pass'
96149efa   Isaac Lewis   working query browse
21
      combrw = Syspro::BusinessObjects::ComBrw.new
dc8aa5b6   Joe Weakley   Rubocop corrections
22
23
      combrw.browse_name = 'InvMaster'
      combrw.start_condition = ''
96149efa   Isaac Lewis   working query browse
24
25
      combrw.return_rows = 5
      combrw.filters = []
dc8aa5b6   Joe Weakley   Rubocop corrections
26
27
      combrw.table_name = 'InvMaster'
      combrw.title = 'StockCodes'
96149efa   Isaac Lewis   working query browse
28
      combrw.columns = [
dc8aa5b6   Joe Weakley   Rubocop corrections
29
        { name: 'StockCode' }
96149efa   Isaac Lewis   working query browse
30
31
      ]
  
0f29247c   Isaac Lewis   add comfch and co...
32
      browse_result = combrw.call(user_id.guid)
96149efa   Isaac Lewis   working query browse
33
  
0f29247c   Isaac Lewis   add comfch and co...
34
35
36
      refute_nil browse_result
    end
  
dc8aa5b6   Joe Weakley   Rubocop corrections
37
    def test_query_query # rubocop:disable Metrics/MethodLength
0f29247c   Isaac Lewis   add comfch and co...
38
      comfnd = Syspro::BusinessObjects::ComFnd.new
dc8aa5b6   Joe Weakley   Rubocop corrections
39
      comfnd.table_name = 'InvMaster'
0f29247c   Isaac Lewis   add comfch and co...
40
41
42
      comfnd.return_rows = 5
      comfnd.columns = [
        {
dc8aa5b6   Joe Weakley   Rubocop corrections
43
          name: 'StockCode'
0f29247c   Isaac Lewis   add comfch and co...
44
45
46
47
        }
      ]
      comfnd.expressions = [
        {
dc8aa5b6   Joe Weakley   Rubocop corrections
48
49
50
51
          andor: 'And',
          column: 'StockCode',
          condition: 'EQ',
          value: '02'
0f29247c   Isaac Lewis   add comfch and co...
52
53
        }
      ]
dc8aa5b6   Joe Weakley   Rubocop corrections
54
      comfnd.order_by = 'StockCode'
0f29247c   Isaac Lewis   add comfch and co...
55
  
724c1cbe   Isaac Lewis   add to readme; fi...
56
      query_result = comfnd.call(user_id.guid)
0f29247c   Isaac Lewis   add comfch and co...
57
  
724c1cbe   Isaac Lewis   add to readme; fi...
58
      refute_nil query_result
0f29247c   Isaac Lewis   add comfch and co...
59
60
61
    end
  
    def test_query_fetch
0f29247c   Isaac Lewis   add comfch and co...
62
      comfch = Syspro::BusinessObjects::ComFch.new
dc8aa5b6   Joe Weakley   Rubocop corrections
63
64
      comfch.table_name = 'InvMaster'
      comfch.key = '02'
0f29247c   Isaac Lewis   add comfch and co...
65
66
      comfch.optional_keys = []
      comfch.full_key_provided = false
dc8aa5b6   Joe Weakley   Rubocop corrections
67
      comfch.default_type = ''
0f29247c   Isaac Lewis   add comfch and co...
68
69
70
71
72
      comfch.espresso_fetch = true
  
      fetch_result = comfch.call(user_id.guid)
  
      refute_nil fetch_result
96149efa   Isaac Lewis   working query browse
73
74
    end
  end