Blame view

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