Skip to content

Commit b9c70bb

Browse files
committed
fixes the sonarQube issues
1 parent d7a116c commit b9c70bb

5 files changed

Lines changed: 27 additions & 27 deletions

File tree

tests/apimatic_core/mocks/http/mock_paginated_http_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def execute(self, request, endpoint_configuration):
136136

137137
if '/transactions/cursor' in request.query_url:
138138
return self.response_factory.create(
139-
status_code=200, reason=None, headers={'Content-Type': 'application/json'},
139+
status_code=200, reason=None, headers=request.headers,
140140
body=ApiHelper.json_serialize({
141141
"data": transaction_batch,
142142
"nextCursor": transaction_batch[-1]['id'] if self._current_index < len(self.transactions) else None
@@ -145,15 +145,15 @@ def execute(self, request, endpoint_configuration):
145145

146146
if '/transactions/offset' in request.query_url:
147147
return self.response_factory.create(
148-
status_code=200, reason=None, headers={'Content-Type': 'application/json'},
148+
status_code=200, reason=None, headers=request.headers,
149149
body=ApiHelper.json_serialize({
150150
"data": transaction_batch
151151
}),
152152
request=request)
153153

154154
if '/transactions/links' in request.query_url:
155155
return self.response_factory.create(
156-
status_code=200, reason=None, headers={'Content-Type': 'application/json'},
156+
status_code=200, reason=None, headers=request.headers,
157157
body=ApiHelper.json_serialize({
158158
"data": transaction_batch,
159159
"links": {
@@ -164,7 +164,7 @@ def execute(self, request, endpoint_configuration):
164164

165165
if '/transactions/page' in request.query_url:
166166
return self.response_factory.create(
167-
status_code=200, reason=None, headers={'Content-Type': 'application/json'},
167+
status_code=200, reason=None, headers=request.headers,
168168
body=ApiHelper.json_serialize({
169169
"data": transaction_batch,
170170
}),

tests/apimatic_core/mocks/models/links.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ class Links(object):
1818
"first": 'first',
1919
"last": 'last',
2020
"prev": 'prev',
21-
"next": 'next'
21+
"_next": 'next'
2222
}
2323

2424
_optionals = [
2525
'first',
2626
'last',
2727
'prev',
28-
'next',
28+
'_next',
2929
]
3030

3131
def __init__(self,
3232
first=ApiHelper.SKIP,
3333
last=ApiHelper.SKIP,
3434
prev=ApiHelper.SKIP,
35-
next=ApiHelper.SKIP):
35+
_next=ApiHelper.SKIP):
3636
"""Constructor for the Links class"""
3737

3838
# Initialize members of the class
@@ -42,8 +42,8 @@ def __init__(self,
4242
self.last = last
4343
if prev is not ApiHelper.SKIP:
4444
self.prev = prev
45-
if next is not ApiHelper.SKIP:
46-
self.next = next
45+
if _next is not ApiHelper.SKIP:
46+
self._next = _next
4747

4848
@classmethod
4949
def from_dictionary(cls,
@@ -67,23 +67,23 @@ def from_dictionary(cls,
6767
first = dictionary.get("first") if dictionary.get("first") else ApiHelper.SKIP
6868
last = dictionary.get("last") if dictionary.get("last") else ApiHelper.SKIP
6969
prev = dictionary.get("prev") if dictionary.get("prev") else ApiHelper.SKIP
70-
next = dictionary.get("next") if dictionary.get("next") else ApiHelper.SKIP
70+
_next = dictionary.get("next") if dictionary.get("next") else ApiHelper.SKIP
7171
# Return an object of this model
7272
return cls(first,
7373
last,
7474
prev,
75-
next)
75+
_next)
7676

7777
def __repr__(self):
7878
return (f'{self.__class__.__name__}('
7979
f'first={(self.first if hasattr(self, "first") else None)!r}, '
8080
f'last={(self.last if hasattr(self, "last") else None)!r}, '
8181
f'prev={(self.prev if hasattr(self, "prev") else None)!r}, '
82-
f'next={(self.next if hasattr(self, "next") else None)!r})')
82+
f'next={(self._next if hasattr(self, "_next") else None)!r})')
8383

8484
def __str__(self):
8585
return (f'{self.__class__.__name__}('
8686
f'first={(self.first if hasattr(self, "first") else None)!s}, '
8787
f'last={(self.last if hasattr(self, "last") else None)!s}, '
8888
f'prev={(self.prev if hasattr(self, "prev") else None)!s}, '
89-
f'next={(self.next if hasattr(self, "next") else None)!s})')
89+
f'next={(self._next if hasattr(self, "_next") else None)!s})')

tests/apimatic_core/mocks/models/transaction.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ class Transaction(object):
1414

1515
# Create a mapping from Model property names to API property names
1616
_names = {
17-
"id": 'id',
17+
"_id": 'id',
1818
"amount": 'amount',
1919
"timestamp": 'timestamp'
2020
}
2121

2222
_optionals = [
23-
'id',
23+
'_id',
2424
'amount',
2525
'timestamp',
2626
]
2727

2828
def __init__(self,
29-
id=ApiHelper.SKIP,
29+
_id=ApiHelper.SKIP,
3030
amount=ApiHelper.SKIP,
3131
timestamp=ApiHelper.SKIP):
3232
"""Constructor for the Transaction class"""
3333

3434
# Initialize members of the class
35-
if id is not ApiHelper.SKIP:
36-
self.id = id
35+
if _id is not ApiHelper.SKIP:
36+
self._id = _id
3737
if amount is not ApiHelper.SKIP:
3838
self.amount = amount
3939
if timestamp is not ApiHelper.SKIP:
@@ -58,22 +58,22 @@ def from_dictionary(cls,
5858
return None
5959

6060
# Extract variables from the dictionary
61-
id = dictionary.get("id") if dictionary.get("id") else ApiHelper.SKIP
61+
_id = dictionary.get("id") if dictionary.get("id") else ApiHelper.SKIP
6262
amount = dictionary.get("amount") if dictionary.get("amount") else ApiHelper.SKIP
6363
timestamp = ApiHelper.HttpDateTime.from_value(dictionary.get("timestamp")).datetime if dictionary.get("timestamp") else ApiHelper.SKIP
6464
# Return an object of this model
65-
return cls(id,
65+
return cls(_id,
6666
amount,
6767
timestamp)
6868

6969
def __repr__(self):
7070
return (f'{self.__class__.__name__}('
71-
f'id={(self.id if hasattr(self, "id") else None)!r}, '
71+
f'id={(self._id if hasattr(self, "_id") else None)!r}, '
7272
f'amount={(self.amount if hasattr(self, "amount") else None)!r}, '
7373
f'timestamp={(self.timestamp if hasattr(self, "timestamp") else None)!r})')
7474

7575
def __str__(self):
7676
return (f'{self.__class__.__name__}('
77-
f'id={(self.id if hasattr(self, "id") else None)!s}, '
77+
f'id={(self._id if hasattr(self, "_id") else None)!s}, '
7878
f'amount={(self.amount if hasattr(self, "amount") else None)!s}, '
7979
f'timestamp={(self.timestamp if hasattr(self, "timestamp") else None)!s})')

tests/apimatic_core/pagination_tests/strategies/test_page_pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_apply_subsequent_call_does_not_increment_page_with_no_results(self, moc
142142
PagePagination, 'get_updated_request_builder'
143143
)
144144

145-
result_rb = pp.apply(mock_paginated_data_subsequent_call_no_results)
145+
pp.apply(mock_paginated_data_subsequent_call_no_results)
146146

147147
assert pp._page_number == 3
148148
mock_get_updated_request_builder.assert_called_once_with(

tests/apimatic_core/pagination_tests/test_pagination_strategy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ def query_params(self):
1919
def header_params(self):
2020
return self._header_params
2121

22-
def __init__(self, template_params=None, query_params=None, header_params=None):
22+
def __init__(self, template_params=None, header_params=None, query_params=None):
2323
super().__init__()
2424
self._template_params = template_params if template_params is not None else {}
2525
self._query_params = query_params if query_params is not None else {}
2626
self._header_params = header_params if header_params is not None else {}
2727

28-
def clone_with(self, template_params=None, query_params=None, header_params=None):
28+
def clone_with(self, template_params=None, header_params=None, query_params=None):
2929
# This mock clone_with will create a new instance with updated params
3030
new_rb = MockRequestBuilder(
3131
template_params=template_params if template_params is not None else self.template_params.copy(),
32-
query_params=query_params if query_params is not None else self.query_params.copy(),
33-
header_params=header_params if header_params is not None else self.header_params.copy()
32+
header_params=header_params if header_params is not None else self.header_params.copy(),
33+
query_params=query_params if query_params is not None else self.query_params.copy()
3434
)
3535
return new_rb
3636

0 commit comments

Comments
 (0)