cli_test.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from __future__ import unicode_literals
  2. from __future__ import absolute_import
  3. import logging
  4. import os
  5. from .. import unittest
  6. from fig.cli import main
  7. from fig.cli.main import TopLevelCommand
  8. from fig.packages.six import StringIO
  9. class CLITestCase(unittest.TestCase):
  10. def test_default_project_name(self):
  11. cwd = os.getcwd()
  12. try:
  13. os.chdir('tests/fixtures/simple-figfile')
  14. command = TopLevelCommand()
  15. self.assertEquals('simplefigfile', command.project_name)
  16. finally:
  17. os.chdir(cwd)
  18. def test_project_name_with_explicit_base_dir(self):
  19. command = TopLevelCommand()
  20. command.base_dir = 'tests/fixtures/simple-figfile'
  21. self.assertEquals('simplefigfile', command.project_name)
  22. def test_project_name_with_explicit_project_name(self):
  23. command = TopLevelCommand()
  24. command.explicit_project_name = 'explicit-project-name'
  25. self.assertEquals('explicitprojectname', command.project_name)
  26. def test_yaml_filename_check(self):
  27. command = TopLevelCommand()
  28. command.base_dir = 'tests/fixtures/longer-filename-figfile'
  29. self.assertTrue(command.project.get_service('definedinyamlnotyml'))
  30. def test_help(self):
  31. command = TopLevelCommand()
  32. with self.assertRaises(SystemExit):
  33. command.dispatch(['-h'], None)
  34. def test_setup_logging(self):
  35. main.setup_logging()
  36. self.assertEqual(logging.getLogger().level, logging.DEBUG)
  37. self.assertEqual(logging.getLogger('requests').propagate, False)