Skip to content

Commit c63a8a7

Browse files
committed
Try to increase test coverage from 89.70% to over 90%
1 parent 798331a commit c63a8a7

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

.coveragerc

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/unit/test_swarm.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
import typing as ty
3+
4+
from ipfshttpclient.client.base import ClientBase, ResponseBase, json_dict_t
5+
from ipfshttpclient.client.swarm import Section
6+
7+
8+
def test_section_addrs():
9+
mock_auth = ('foo', 'bar')
10+
11+
mock_result = {
12+
'Addrs': {
13+
'hash123': [
14+
'multiaddr234'
15+
]
16+
}
17+
}
18+
19+
mock_result = [{
20+
'Addrs': {
21+
'hash123': [
22+
'multiaddr234'
23+
]
24+
}
25+
}]
26+
27+
class MockClient:
28+
@staticmethod
29+
def request(url: str, decoder: str, **kwargs) -> ty.List[ty.Dict[str, ty.Dict[str, ty.List[str]]]]:
30+
assert url == '/swarm/addrs'
31+
assert decoder == 'json'
32+
assert kwargs == {'auth': mock_auth}
33+
34+
return mock_result
35+
36+
mc = MockClient()
37+
38+
cb = ClientBase(session=False)
39+
cb._client = mc
40+
section = Section(cb)
41+
42+
response_base = section.addrs(auth=mock_auth)
43+
assert isinstance(response_base, ResponseBase)
44+
45+
expected = ResponseBase(ty.cast(json_dict_t, mock_result[0]))
46+
assert response_base == expected

0 commit comments

Comments
 (0)