Skip to content

Commit 51b3364

Browse files
Bugfix
1 parent 3b3a5a5 commit 51b3364

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

fast_bitrix24/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.8.1"
1+
__version__ = "1.8.2"

fast_bitrix24/server_response.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ def extract_errors(self):
7171
def is_batch(self) -> bool:
7272
return isinstance(self.result, dict) and "result" in self.result
7373

74-
def extract_from_single_response(self, result: dict):
74+
def extract_from_single_response(self, result):
75+
# Сначала проверяем, является ли result списком
76+
if isinstance(result, list):
77+
return result
78+
7579
# если результат вызова содержит только словарь из одного элемента {ключ: содержимое},
7680
# то вернуть это содержимое.
7781
# См. https://github.com/leshchenko1979/fast_bitrix24/issues/132
7882

7983
# метод `crm.stagehistory.list` возвращает dict["items", list] --
8084
# разворачиваем его в список
81-
8285
return next(iter(result.values())) if self.is_nested(result) else result
8386

8487
@staticmethod

tests/test_server_responses.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_call_several_success(bx_dummy):
7575
assert len(results) == 3
7676
assert isinstance(results[0], dict)
7777

78-
# нужен какой-то другой тест для контроля ��орядока результатов
78+
# нужен какой-то другой тест для контроля орядока результатов
7979
# assert [result["ID"] for result in results] == ID_list, "Incorrect order of IDs"
8080

8181

@@ -321,3 +321,43 @@ def test_crm_contact_add_batch(bx_dummy):
321321

322322
# Проверяем что результат - это ID созданного контакта
323323
assert result == 58943
324+
325+
326+
def test_crm_contact_list(bx_dummy):
327+
response = {
328+
'result': [
329+
{
330+
'ID': '10',
331+
'NAME': 'Абдуалимова Татьяна Александровна',
332+
'SECOND_NAME': None,
333+
'LAST_NAME': None
334+
}
335+
],
336+
'total': 1,
337+
'time': {
338+
'start': 1731743829.0188,
339+
'finish': 1731743829.06444,
340+
'duration': 0.045639991760253906,
341+
'processing': 0.019975900650024414,
342+
'date_start': '2024-11-16T10:57:09+03:00',
343+
'date_finish': '2024-11-16T10:57:09+03:00',
344+
'operating_reset_at': 1731744429,
345+
'operating': 0
346+
}
347+
}
348+
349+
bx_dummy.srh = MockSRH(response)
350+
results = bx_dummy.get_all(
351+
'crm.contact.list',
352+
{
353+
'params': {
354+
'select': ['ID', 'NAME', 'SECOND_NAME', 'LAST_NAME'],
355+
'filter': {'=ID': ['10']}
356+
}
357+
}
358+
)
359+
360+
assert isinstance(results, list)
361+
assert len(results) == 1
362+
assert results[0]['ID'] == '10'
363+
assert results[0]['NAME'] == 'Абдуалимова Татьяна Александровна'

0 commit comments

Comments
 (0)