Exemplo n.º 1
0
 def test_adjacent_port_to_many_to_one(self):
     port_mappings = PortMappings()
     port_mappings.add([7000, 7002], 7000)
     port_mappings.add(6999)
     expected_result = {
         "6999/tcp": 6999,
         "7000/tcp": [7000, 7001, 7002],
     }
     result = port_mappings.to_dict()
     assert result == expected_result
Exemplo n.º 2
0
 def test_many_to_one_adjacent_to_uniform(self):
     port_mappings = PortMappings()
     port_mappings.add(5002)
     port_mappings.add(5003)
     port_mappings.add([5004, 5006], 5004)
     expected_result = {
         "5002/tcp": 5002,
         "5003/tcp": 5003,
         "5004/tcp": [5004, 5005, 5006],
     }
     result = port_mappings.to_dict()
     assert result == expected_result
Exemplo n.º 3
0
 def test_port_ranges_with_bind_host_to_dict(self):
     port_mappings = PortMappings(bind_host="0.0.0.0")
     port_mappings.add(5000, 6000)
     port_mappings.add(5001, 7000)
     port_mappings.add(5003, 8000)
     port_mappings.add([5004, 5006], 9000)
     result = port_mappings.to_dict()
     expected_result = {
         "6000/tcp": ("0.0.0.0", 5000),
         "7000/tcp": ("0.0.0.0", 5001),
         "8000/tcp": ("0.0.0.0", 5003),
         "9000/tcp": ("0.0.0.0", [5004, 5005, 5006]),
     }
     assert result == expected_result