Blame view

test/query_test.rb 1.55 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
dc8aa5b6   Joe Weakley   Rubocop corrections
6
7
    def test_query_browse # rubocop:disable Metrics/MethodLength
      user_id = Syspro::Logon.logon('wland', 'piperita2016', 'L', '')
96149efa   Isaac Lewis   working query browse
8
9
  
      combrw = Syspro::BusinessObjects::ComBrw.new
dc8aa5b6   Joe Weakley   Rubocop corrections
10
11
      combrw.browse_name = 'InvMaster'
      combrw.start_condition = ''
96149efa   Isaac Lewis   working query browse
12
13
      combrw.return_rows = 5
      combrw.filters = []
dc8aa5b6   Joe Weakley   Rubocop corrections
14
15
      combrw.table_name = 'InvMaster'
      combrw.title = 'StockCodes'
96149efa   Isaac Lewis   working query browse
16
      combrw.columns = [
dc8aa5b6   Joe Weakley   Rubocop corrections
17
        { name: 'StockCode' }
96149efa   Isaac Lewis   working query browse
18
19
      ]
  
0f29247c   Isaac Lewis   add comfch and co...
20
      browse_result = combrw.call(user_id.guid)
96149efa   Isaac Lewis   working query browse
21
  
0f29247c   Isaac Lewis   add comfch and co...
22
23
24
      refute_nil browse_result
    end
  
dc8aa5b6   Joe Weakley   Rubocop corrections
25
26
    def test_query_query # rubocop:disable Metrics/MethodLength
      user_id = Syspro::Logon.logon('wland', 'piperita2016', 'L', '')
0f29247c   Isaac Lewis   add comfch and co...
27
28
  
      comfnd = Syspro::BusinessObjects::ComFnd.new
dc8aa5b6   Joe Weakley   Rubocop corrections
29
      comfnd.table_name = 'InvMaster'
0f29247c   Isaac Lewis   add comfch and co...
30
31
32
      comfnd.return_rows = 5
      comfnd.columns = [
        {
dc8aa5b6   Joe Weakley   Rubocop corrections
33
          name: 'StockCode'
0f29247c   Isaac Lewis   add comfch and co...
34
35
36
37
        }
      ]
      comfnd.expressions = [
        {
dc8aa5b6   Joe Weakley   Rubocop corrections
38
39
40
41
          andor: 'And',
          column: 'StockCode',
          condition: 'EQ',
          value: '02'
0f29247c   Isaac Lewis   add comfch and co...
42
43
        }
      ]
dc8aa5b6   Joe Weakley   Rubocop corrections
44
      comfnd.order_by = 'StockCode'
0f29247c   Isaac Lewis   add comfch and co...
45
  
724c1cbe   Isaac Lewis   add to readme; fi...
46
      query_result = comfnd.call(user_id.guid)
0f29247c   Isaac Lewis   add comfch and co...
47
  
724c1cbe   Isaac Lewis   add to readme; fi...
48
      refute_nil query_result
0f29247c   Isaac Lewis   add comfch and co...
49
50
51
    end
  
    def test_query_fetch
dc8aa5b6   Joe Weakley   Rubocop corrections
52
      user_id = Syspro::Logon.logon('wland', 'piperita2016', 'L', '')
0f29247c   Isaac Lewis   add comfch and co...
53
54
  
      comfch = Syspro::BusinessObjects::ComFch.new
dc8aa5b6   Joe Weakley   Rubocop corrections
55
56
      comfch.table_name = 'InvMaster'
      comfch.key = '02'
0f29247c   Isaac Lewis   add comfch and co...
57
58
      comfch.optional_keys = []
      comfch.full_key_provided = false
dc8aa5b6   Joe Weakley   Rubocop corrections
59
      comfch.default_type = ''
0f29247c   Isaac Lewis   add comfch and co...
60
61
62
63
64
      comfch.espresso_fetch = true
  
      fetch_result = comfch.call(user_id.guid)
  
      refute_nil fetch_result
96149efa   Isaac Lewis   working query browse
65
66
    end
  end