test_.py 693 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. import pytest
  3. import shutil
  4. import subprocess
  5. import tooncher
  6. def test_start_engine():
  7. p = tooncher.start_engine(
  8. engine_path=shutil.which('printenv'),
  9. gameserver='gameserver',
  10. playcookie='cookie',
  11. stdout=subprocess.PIPE,
  12. stderr=subprocess.PIPE,
  13. )
  14. assert isinstance(p, subprocess.Popen)
  15. stdout, stderr = p.communicate()
  16. assert b'' == stderr
  17. env = stdout.strip().split(b'\n')
  18. assert b'TTR_GAMESERVER=gameserver' in env
  19. assert b'TTR_PLAYCOOKIE=cookie' in env
  20. def test_api_request_invasions():
  21. resp_data = tooncher.api_request(tooncher.INVASIONS_API_URL)
  22. assert 'invasions' in resp_data