Skip to content

Commit 51eb09c

Browse files
author
Gabriele Barcella
committed
test: added unit tests
1 parent c14701d commit 51eb09c

16 files changed

Lines changed: 497 additions & 71 deletions

spec/api/price_lists_api_spec.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
before do
2121
# run before each test
2222
@api_instance = FattureInCloud_Ruby_Sdk::PriceListsApi.new
23+
24+
@get_price_lists_response_obj = { data: [{ id: '10', name: 'listino', prices_type: 'net', is_default: true, valid_from: '2025-01-01', valid_to: '2025-12-01', type: 'sell' }, { id: '11', name: 'listino-test', prices_type: 'gross', is_default: true, valid_from: '2025-01-01', valid_to: '2025-01-01', type: 'purchase' }] }
25+
allow(@api_instance).to receive(:get_price_lists) { @get_price_lists_response_obj }
26+
27+
@get_price_list_items_response_obj = { data: { '1': { price: 3.5 }, '2': { price: 5 } } }
28+
allow(@api_instance).to receive(:get_price_list_items) { @get_price_list_items_response_obj }
29+
2330
end
2431

2532
after do
@@ -36,12 +43,17 @@
3643
# Get PriceList Items List
3744
# Retrieves all the Items of a PriceList
3845
# @param company_id The ID of the company.
39-
# @param price_list_id
46+
# @param price_list_id
4047
# @param [Hash] opts the optional parameters
4148
# @return [GetPriceListItemsResponse]
4249
describe 'get_price_list_items test' do
4350
it 'should work' do
44-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
51+
response = @api_instance.get_price_list_items(2, '10')
52+
response_obj = JSON.parse(response.to_json, object_class: OpenStruct)
53+
expected_json = @get_price_list_items_response_obj.to_json
54+
actual_json = response.to_json
55+
56+
expect(actual_json).to eq(expected_json)
4557
end
4658
end
4759

@@ -53,7 +65,12 @@
5365
# @return [ListPriceListsResponse]
5466
describe 'get_price_lists test' do
5567
it 'should work' do
56-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
68+
response = @api_instance.get_price_lists(2)
69+
response_obj = JSON.parse(response.to_json, object_class: OpenStruct)
70+
expected_json = @get_price_lists_response_obj.to_json
71+
actual_json = response.to_json
72+
73+
expect(actual_json).to eq(expected_json)
5774
end
5875
end
5976

spec/models/entity_client_pre_create_info_spec.rb

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,54 +18,105 @@
1818
# Automatically generated by openapi-generator (https://openapi-generator.tech)
1919
# Please update as you see appropriate
2020
describe FattureInCloud_Ruby_Sdk::EntityClientPreCreateInfo do
21-
let(:instance) { FattureInCloud_Ruby_Sdk::EntityClientPreCreateInfo.new }
21+
instance = FattureInCloud_Ruby_Sdk::EntityClientPreCreateInfo.new
22+
instance.countries_list = ['Italy']
23+
instance.payment_methods_list = [
24+
{
25+
id: 555,
26+
name: 'Rimessa diretta',
27+
is_default: false,
28+
details: [],
29+
}
30+
]
31+
instance.payment_accounts_list = [
32+
{
33+
id: 0,
34+
name: 'Conto Banca Intesa',
35+
type: 'standard',
36+
iban: 'string',
37+
sia: 'string',
38+
cuc: 'string',
39+
virtual: true
40+
}
41+
]
42+
instance.vat_types_list = [
43+
{
44+
id: 0,
45+
value: 22,
46+
description: 'Iva 22%',
47+
notes: 'string',
48+
is_disabled: false
49+
}
50+
]
51+
instance.price_lists = [
52+
{
53+
id: '10',
54+
name: 'listino',
55+
prices_type: 'net',
56+
is_default: true,
57+
valid_from: '2025-01-01',
58+
valid_to: '2025-12-01',
59+
type: 'sell'
60+
},
61+
{
62+
id: '11',
63+
name: 'listino-test',
64+
prices_type: 'gross',
65+
is_default: true,
66+
valid_from: '2025-01-01',
67+
valid_to: '2025-01-01',
68+
type: 'purchase'
69+
}
70+
]
71+
instance.limit = 10
72+
instance.usage = 10
73+
2274

2375
describe 'test an instance of EntityClientPreCreateInfo' do
2476
it 'should create an instance of EntityClientPreCreateInfo' do
25-
# uncomment below to test the instance creation
26-
# expect(instance).to be_instance_of(FattureInCloud_Ruby_Sdk::EntityClientPreCreateInfo)
77+
expect(instance).to be_instance_of(FattureInCloud_Ruby_Sdk::EntityClientPreCreateInfo)
2778
end
2879
end
2980

3081
describe 'test attribute "countries_list"' do
3182
it 'should work' do
32-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
83+
expect(instance.countries_list).to be_a_kind_of(Array)
3384
end
3485
end
3586

3687
describe 'test attribute "payment_methods_list"' do
3788
it 'should work' do
38-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
89+
expect(instance.payment_methods_list).to be_a_kind_of(Array)
3990
end
4091
end
4192

4293
describe 'test attribute "payment_accounts_list"' do
4394
it 'should work' do
44-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
95+
expect(instance.payment_accounts_list).to be_a_kind_of(Array)
4596
end
4697
end
4798

4899
describe 'test attribute "vat_types_list"' do
49100
it 'should work' do
50-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
101+
expect(instance.vat_types_list).to be_a_kind_of(Array)
51102
end
52103
end
53104

54105
describe 'test attribute "price_lists"' do
55106
it 'should work' do
56-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
107+
expect(instance.price_lists).to be_a_kind_of(Array)
57108
end
58109
end
59110

60111
describe 'test attribute "limit"' do
61112
it 'should work' do
62-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
113+
expect(instance.limit).to be_a_kind_of(Numeric)
63114
end
64115
end
65116

66117
describe 'test attribute "usage"' do
67118
it 'should work' do
68-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
119+
expect(instance.limit).to be_a_kind_of(Numeric)
69120
end
70121
end
71122

spec/models/get_bin_issued_document_response_spec.rb

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,127 @@
1818
# Automatically generated by openapi-generator (https://openapi-generator.tech)
1919
# Please update as you see appropriate
2020
describe FattureInCloud_Ruby_Sdk::GetBinIssuedDocumentResponse do
21-
let(:instance) { FattureInCloud_Ruby_Sdk::GetBinIssuedDocumentResponse.new }
21+
instance = FattureInCloud_Ruby_Sdk::GetBinIssuedDocumentResponse.new
22+
instance.data = {
23+
id: 12345,
24+
type: 'invoice',
25+
year: 2021,
26+
numeration: 'rec123',
27+
subject: '',
28+
visible_subject: '',
29+
rc_center: '',
30+
stamp_duty: 0,
31+
use_gross_prices: false,
32+
e_invoice: false,
33+
delivery_note: false,
34+
accompanying_invoice: false,
35+
amount_net: 68.18,
36+
amount_vat: 6.82,
37+
amount_gross: 75,
38+
amount_due_discount: 0,
39+
amount_rivalsa: 0,
40+
amount_cassa: 0,
41+
amount_withholding_tax: 0,
42+
amount_other_withholding_tax: 0,
43+
h_margins: 15,
44+
v_margins: 16,
45+
show_payment_method: false,
46+
show_payments: true,
47+
show_totals: 'all',
48+
show_notification_button: false,
49+
is_marked: false,
50+
entity: {
51+
id: 54321,
52+
name: 'Mary Red S.r.L.',
53+
vat_number: 'IT05432181211',
54+
tax_code: 'IT05432181211',
55+
address_street: 'Corso impero, 66',
56+
address_postal_code: '20900',
57+
address_city: 'Milano',
58+
address_province: 'MI',
59+
address_extra: '',
60+
country: 'Italia',
61+
certified_email: 'mary@pec.red.com',
62+
ei_code: 'ABCXCR1'
63+
},
64+
date: '2021-08-20',
65+
number: 1,
66+
currency: {
67+
id: 'EUR',
68+
exchange_rate: '1.00000',
69+
symbol: '€'
70+
},
71+
language: {
72+
code: 'it',
73+
name: 'Italiano'
74+
},
75+
notes: '',
76+
rivalsa: 0,
77+
cassa: 0,
78+
withholding_tax: 0,
79+
withholding_tax_taxable: 100,
80+
other_withholding_tax: 0,
81+
payment_method: {
82+
id: 4,
83+
name: 'Credit card'
84+
},
85+
use_split_payment: false,
86+
items_list: [
87+
{
88+
product_id: 5432,
89+
code: 'SG3',
90+
name: 'Soggiorno',
91+
measure: '',
92+
net_price: 68.18182,
93+
category: '',
94+
id: 277876033,
95+
gross_price: 75,
96+
apply_withholding_taxes: true,
97+
discount: 0,
98+
discount_highlight: false,
99+
in_dn: false,
100+
qty: 1,
101+
vat: {
102+
id: 3,
103+
value: 10,
104+
description: ''
105+
},
106+
stock: false,
107+
description: '',
108+
not_taxable: false
109+
}
110+
],
111+
payments_list: [
112+
{
113+
amount: 75,
114+
due_date: '2020-08-23',
115+
id: 69078013,
116+
payment_terms: {
117+
days: 0,
118+
type: 'standard'
119+
},
120+
status: 'not_paid',
121+
}
122+
],
123+
attachment_url: 'kdijrnf893hnwkfk45f50f.pdf',
124+
next_due_date: '2020-08-23',
125+
template: {
126+
id: 2821,
127+
name: 'Light Smoke'
128+
},
129+
url: 'y12h45rn9yf2mse0p43t7ec90vr.pdf',
130+
show_tspay_button: false
131+
}
22132

23133
describe 'test an instance of GetBinIssuedDocumentResponse' do
24134
it 'should create an instance of GetBinIssuedDocumentResponse' do
25-
# uncomment below to test the instance creation
26-
# expect(instance).to be_instance_of(FattureInCloud_Ruby_Sdk::GetBinIssuedDocumentResponse)
135+
expect(instance).to be_instance_of(FattureInCloud_Ruby_Sdk::GetBinIssuedDocumentResponse)
27136
end
28137
end
29138

30139
describe 'test attribute "data"' do
31140
it 'should work' do
32-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
141+
expect(instance.data).to be_a_kind_of(Object)
33142
end
34143
end
35144

spec/models/get_bin_received_document_response_spec.rb

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,65 @@
1818
# Automatically generated by openapi-generator (https://openapi-generator.tech)
1919
# Please update as you see appropriate
2020
describe FattureInCloud_Ruby_Sdk::GetBinReceivedDocumentResponse do
21-
let(:instance) { FattureInCloud_Ruby_Sdk::GetBinReceivedDocumentResponse.new }
21+
instance = FattureInCloud_Ruby_Sdk::GetBinReceivedDocumentResponse.new
22+
instance.data = {
23+
id: 12345,
24+
type: 'expense',
25+
description: 'Soggiorno di lavoro',
26+
amortization: 1,
27+
rc_center: '',
28+
invoice_number: '',
29+
is_marked: false,
30+
is_detailed: false,
31+
e_invoice: false,
32+
entity: {
33+
id: 111,
34+
name: 'Hotel Rubino Palace'
35+
},
36+
date: '2021-08-15',
37+
next_due_date: '2021-08-15',
38+
currency: {
39+
id: 'EUR',
40+
exchange_rate: '1.00000',
41+
symbol: '€'
42+
},
43+
amount_net: 592,
44+
amount_vat: 0,
45+
amount_gross: 592,
46+
amount_withholding_tax: 0,
47+
amount_other_withholding_tax: 0,
48+
tax_deductibility: 50,
49+
vat_deductibility: 100,
50+
payments_list: [
51+
{
52+
amount: 592,
53+
due_date: '2021-08-15',
54+
paid_date: '2021-08-15',
55+
id: 777,
56+
payment_terms: {
57+
days: 0,
58+
type: 'standard'
59+
},
60+
status: 'paid',
61+
payment_account: {
62+
id: 222,
63+
name: 'Contanti',
64+
virtual: false
65+
}
66+
}
67+
],
68+
attachment_url: 'spesa_ger5i783t45hu6ti.pdf'
69+
}
2270

2371
describe 'test an instance of GetBinReceivedDocumentResponse' do
2472
it 'should create an instance of GetBinReceivedDocumentResponse' do
25-
# uncomment below to test the instance creation
26-
# expect(instance).to be_instance_of(FattureInCloud_Ruby_Sdk::GetBinReceivedDocumentResponse)
73+
expect(instance).to be_instance_of(FattureInCloud_Ruby_Sdk::GetBinReceivedDocumentResponse)
2774
end
2875
end
2976

3077
describe 'test attribute "data"' do
3178
it 'should work' do
32-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
79+
expect(instance.data).to be_a_kind_of(Object)
3380
end
3481
end
3582

0 commit comments

Comments
 (0)