def test_parse_services_normal(): config = ''' postgres: postgres:10 redis: redis:latest ''' services = parse_services(config) assert len(services) == 2 assert services['postgres']['name'] == 'postgres' assert services['postgres']['image'] == 'postgres:10' assert services['redis']['name'] == 'redis' assert services['redis']['image'] == 'redis:latest'
def test_parse_services_mixed_no_image(): config = ''' postgres: redis: ''' services = parse_services(config) assert len(services) == 2 assert services['postgres']['name'] == 'postgres' assert services['postgres']['image'] == 'postgres' assert services['redis']['name'] == 'redis' assert services['redis']['image'] == 'redis'
def test_parse_services_with_options_mixed(): config = ''' postgres: name: pgdb image: postgres:10 redis: redis:latest ''' services = parse_services(config) assert len(services) == 2 assert services['pgdb']['name'] == 'pgdb' assert services['pgdb']['image'] == 'postgres:10' assert services['redis']['name'] == 'redis' assert services['redis']['image'] == 'redis:latest'
def test_parse_services_with_variables(): config = ''' postgres: image: postgres:10 environment: POSTGRES_USERNAME: myuser POSTGRES_PASSWORD: $3cr3t POSTGRES_DB: mydb _templates: POSTGRES_PORT: "{env[POSTGRES_PORT_5432_TCP_PORT]/}" DATABASE_URL: "postgres://*****:*****@localhost:{env[POSTGRES_PORT_5432_TCP_PORT]/mydb}" redis: redis:latest ''' services = parse_services(config) assert len(services) == 2 assert services['postgres']['name'] == 'postgres' assert services['postgres']['image'] == 'postgres:10' assert services['redis']['name'] == 'redis' assert services['redis']['image'] == 'redis:latest'