From fac49b62b6208e4c8bbe62ed246abd2cedfad25f Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 23 Sep 2014 09:28:08 -0700 Subject: [PATCH] Support setting project name from the environment. Signed-off-by: Daniel Nephin --- fig/cli/command.py | 1 + tests/unit/cli_test.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/fig/cli/command.py b/fig/cli/command.py index b21abe5b4..dd98efef5 100644 --- a/fig/cli/command.py +++ b/fig/cli/command.py @@ -81,6 +81,7 @@ class Command(DocoptCommand): def normalize_name(name): return re.sub(r'[^a-zA-Z0-9]', '', name) + project_name = project_name or os.environ.get('FIG_PROJECT_NAME') if project_name is not None: return normalize_name(project_name) diff --git a/tests/unit/cli_test.py b/tests/unit/cli_test.py index 77f58511f..c9151165e 100644 --- a/tests/unit/cli_test.py +++ b/tests/unit/cli_test.py @@ -35,6 +35,14 @@ class CLITestCase(unittest.TestCase): project_name = command.get_project_name(None, project_name=name) self.assertEquals('explicitprojectname', project_name) + def test_project_name_from_environment(self): + command = TopLevelCommand() + name = 'namefromenv' + with mock.patch.dict(os.environ): + os.environ['FIG_PROJECT_NAME'] = name + 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-figfile'