MCPcopy Index your code
hub / github.com/docker/docker-py / test_list_networks

Method test_list_networks

tests/unit/api_network_test.py:10–43  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

8
9class NetworkTest(BaseAPIClientTest):
10 def test_list_networks(self):
11 networks = [
12 {
13 "name": "none",
14 "id": "8e4e55c6863ef424",
15 "type": "null",
16 "endpoints": []
17 },
18 {
19 "name": "host",
20 "id": "062b6d9ea7913fde",
21 "type": "host",
22 "endpoints": []
23 },
24 ]
25
26 get = mock.Mock(return_value=response(
27 status_code=200, content=json.dumps(networks).encode('utf-8')))
28
29 with mock.patch('docker.api.client.APIClient.get', get):
30 assert self.client.networks() == networks
31
32 assert get.call_args[0][0] == f"{url_prefix}networks"
33
34 filters = json.loads(get.call_args[1]['params']['filters'])
35 assert not filters
36
37 self.client.networks(names=['foo'])
38 filters = json.loads(get.call_args[1]['params']['filters'])
39 assert filters == {'name': ['foo']}
40
41 self.client.networks(ids=['123'])
42 filters = json.loads(get.call_args[1]['params']['filters'])
43 assert filters == {'id': ['123']}
44
45 def test_create_network(self):
46 network_data = {

Callers

nothing calls this directly

Calls 2

responseFunction · 0.85
networksMethod · 0.45

Tested by

no test coverage detected