Support fig.y(a)ml and show a deprecation warning
Closes #864 Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
9bc7604e0e
commit
7c087f1c07
3 changed files with 77 additions and 18 deletions
|
|
@ -2,12 +2,15 @@ from __future__ import unicode_literals
|
|||
from __future__ import absolute_import
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
import shutil
|
||||
from .. import unittest
|
||||
|
||||
import mock
|
||||
|
||||
from compose.cli import main
|
||||
from compose.cli.main import TopLevelCommand
|
||||
from compose.cli.errors import ComposeFileNotFound
|
||||
from six import StringIO
|
||||
|
||||
|
||||
|
|
@ -57,12 +60,30 @@ class CLITestCase(unittest.TestCase):
|
|||
project_name = command.get_project_name(None)
|
||||
self.assertEquals(project_name, name)
|
||||
|
||||
def test_yaml_filename_check(self):
|
||||
command = TopLevelCommand()
|
||||
command.base_dir = 'tests/fixtures/longer-filename-composefile'
|
||||
with mock.patch('compose.cli.command.log', autospec=True) as mock_log:
|
||||
self.assertTrue(command.get_config_path())
|
||||
self.assertEqual(mock_log.warning.call_count, 2)
|
||||
def test_filename_check(self):
|
||||
self.assertEqual('docker-compose.yml', get_config_filename_for_files([
|
||||
'docker-compose.yml',
|
||||
'docker-compose.yaml',
|
||||
'fig.yml',
|
||||
'fig.yaml',
|
||||
]))
|
||||
|
||||
self.assertEqual('docker-compose.yaml', get_config_filename_for_files([
|
||||
'docker-compose.yaml',
|
||||
'fig.yml',
|
||||
'fig.yaml',
|
||||
]))
|
||||
|
||||
self.assertEqual('fig.yml', get_config_filename_for_files([
|
||||
'fig.yml',
|
||||
'fig.yaml',
|
||||
]))
|
||||
|
||||
self.assertEqual('fig.yaml', get_config_filename_for_files([
|
||||
'fig.yaml',
|
||||
]))
|
||||
|
||||
self.assertRaises(ComposeFileNotFound, lambda: get_config_filename_for_files([]))
|
||||
|
||||
def test_get_project(self):
|
||||
command = TopLevelCommand()
|
||||
|
|
@ -81,3 +102,21 @@ class CLITestCase(unittest.TestCase):
|
|||
main.setup_logging()
|
||||
self.assertEqual(logging.getLogger().level, logging.DEBUG)
|
||||
self.assertEqual(logging.getLogger('requests').propagate, False)
|
||||
|
||||
|
||||
def get_config_filename_for_files(filenames):
|
||||
project_dir = tempfile.mkdtemp()
|
||||
try:
|
||||
make_files(project_dir, filenames)
|
||||
command = TopLevelCommand()
|
||||
command.base_dir = project_dir
|
||||
return os.path.basename(command.get_config_path())
|
||||
finally:
|
||||
shutil.rmtree(project_dir)
|
||||
|
||||
|
||||
def make_files(dirname, filenames):
|
||||
for fname in filenames:
|
||||
with open(os.path.join(dirname, fname), 'w') as f:
|
||||
f.write('')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue