forked from vjebelev/ruby-netsuite-client-gem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netsuite_client_test.rb
95 lines (81 loc) · 2.92 KB
/
netsuite_client_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
class NetsuiteClientClient < Test::Unit::TestCase
include NetSuite::SOAP
def setup
ENV['NS_ENDPOINT_URL'] ||= NetSuite::SOAP::NetSuitePortType::DefaultEndpointUrl.sub(/webservices/, "webservices.sandbox")
unless ENV['NS_ACCOUNT_ID'] && ENV['NS_EMAIL'] && ENV['NS_PASSWORD']
puts "Ensure that all your environment variables are set: NS_ACCOUNT_ID, NS_EMAIL, NS_PASSWORD"
exit(-1)
end
@client = NetsuiteClient.new(:account_id => ENV['NS_ACCOUNT_ID'], :email => ENV['NS_EMAIL'], :password => ENV['NS_PASSWORD'], :role => ENV['NS_ROLE'], :endpoint_url => ENV['NS_ENDPOINT_URL'])
@client.debug = true
end
def test_init
assert_not_nil @client
end
def test_find_by_internal_id
records = @client.find_by_internal_ids('TransactionSearchBasic', [1])
assert_equal [], records
end
def test_get
record = @client.get('RecordType::PaymentMethod', 1)
assert_not_nil record
assert_equal 1, record.xmlattr_internalId.to_i
assert_equal 'NetSuite::SOAP::PaymentMethod', record.class.to_s
end
def test_get_all
records = @client.get_all('GetAllRecordType::Currency')
assert records.any?
assert records.all? {|r| r.class.to_s == 'NetSuite::SOAP::Currency'}
end
# inventory item tests are currently disabled
# FIXME: 2011_2 requires cogs and asset accounts
# def test_add_inventory_item
# ref = InventoryItem.new
# ref.itemId = 'test inventory item'
# res = @client.add(ref)
# assert_not_nil res
# assert res.success? || res.error_code == 'DUP_ITEM'
# end
# FIXME
# def test_find_by_item_id
# test_add_inventory_item
# item = @client.find_by('ItemSearchBasic', 'itemId', 'test inventory item')
#
# assert_not_nil item
# assert_equal 'NetSuite::SOAP::RecordList', item.class.to_s
# assert_equal 1, item.size
# assert_equal 'NetSuite::SOAP::InventoryItem', item[0].class.to_s
# end
# FIXME
# def test_update_inventory_item
# test_add_inventory_item
# new_name = String.random_string
#
# item = @client.find_by('ItemSearchBasic', 'itemId', 'test inventory item')[0]
# assert item.displayName != new_name
#
# ref = InventoryItem.new
# ref.xmlattr_internalId = item.xmlattr_internalId
# ref.displayName = new_name
# res = @client.update(ref)
# assert_not_nil res
# assert res.success?
#
# item = @client.find_by('ItemSearchBasic', 'itemId', 'test inventory item')[0]
# assert item.displayName == new_name
# end
# FIXME
# def test_delete_inventory_item
# test_add_inventory_item
# item = @client.find_by('ItemSearchBasic', 'itemId', 'test inventory item')[0]
# assert_not_nil item
#
# ref = InventoryItem.new
# ref.xmlattr_internalId = item.xmlattr_internalId
# res = @client.delete(ref)
# assert_not_nil res
# assert res.success?
# assert_nil @client.find_by('ItemSearchBasic', 'itemId', 'test inventory item')[0]
# end
end