cli_test.py 1.3 KB

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