test_compose.py 609 B

123456789101112131415161718192021
  1. #!/usr/bin/env python
  2. import time
  3. import pytest
  4. import requests
  5. pytestmark = pytest.mark.compose
  6. def test_compose_simple(compose, datadir):
  7. with compose(datadir / 'docker-compose.yml') as project:
  8. j = project.ps()
  9. assert len(j) == 1
  10. assert j[0]['Name'] == 'test_compose-server-1'
  11. assert j[0]['State'] == 'running'
  12. assert j[0]['Publishers'][0]['TargetPort'] == 8000
  13. port = j[0]['Publishers'][0]['PublishedPort']
  14. # XXX: should retry with a timeout
  15. time.sleep(.5)
  16. assert requests.get(f'http://localhost:{port}').status_code == 200