def testGivenDictKeyedWithFigEnvvarsWillGroupValuesByContainerName(self): environ = { 'DB_1_PORT_80_TCP': 'tcp://172.2.0.1:5000', 'DB_2_PORT_90_TCP': 'tcp://172.2.0.1:5001', 'REDIS_3_PORT_30_TCP': 'tcp://172.2.0.1:5002', } self.assertSetEqual(set(groupby_containers(environ).keys()), {'db', 'redis'})
def testPortsWillBeMergedIntoListsAndSortedAscending(self): environ = { 'DB_1_PORT_5000_TCP': "tcp://172.0.2.1:5000", 'DB_1_PORT_6000_TCP': "tcp://172.0.2.1:6000", 'HTTP_1_PORT_80_TCP': "tcp://172.0.2.3:80", 'HTTP_2_PORT_80_TCP': "tcp://172.0.2.4:80", } grouped = groupby_containers(environ) self.assertListEqual(grouped['db'][0]['ports'], ['5000', '6000']) self.assertListEqual(grouped['http'][0]['ports'], ['80']) self.assertListEqual(grouped['http'][1]['ports'], ['80'])