예제 #1
0
    def test_echo_detected_environment_not_env(self, caplog):
        """Environment helper note when DEPLOY_ENVIRONMENT is not set."""
        context = Context(env_name='test',
                          env_region='us-east-1',
                          env_root='./')
        expected = [
            '', 'Environment "test" was determined from the '
            'current git branch or parent directory.',
            'If this is not the environment name, update '
            'the branch/folder name or set an override value via the '
            'DEPLOY_ENVIRONMENT environment variable', ''
        ]

        with caplog.at_level(logging.INFO):
            context.echo_detected_environment()

        assert [rec.message for rec in caplog.records] == expected
예제 #2
0
    def test_echo_detected_environment_from_env(self, caplog):
        """Environment helper note when DEPLOY_ENVIRONMENT is set."""
        context = Context(env_name='test',
                          env_region='us-east-1',
                          env_root='./',
                          env_vars={'DEPLOY_ENVIRONMENT': 'test'})
        expected = [
            '', 'Environment "test" was determined from the '
            'DEPLOY_ENVIRONMENT environment variable.',
            'If this is not correct, update the value (or '
            'unset it to fall back to the name of the current git '
            'branch or parent directory).', ''
        ]

        with caplog.at_level(logging.INFO):
            context.echo_detected_environment()

        assert [rec.message for rec in caplog.records] == expected
예제 #3
0
    def test_echo_detected_environment_not_env(self):
        """Environment helper note when DEPLOY_ENVIRONMENT is not set."""
        if sys.version_info[0] < 3:
            return  # this test method was not added until 3.4

        context = Context(env_name='test',
                          env_region='us-east-1',
                          env_root='./')
        expected = [
            'INFO:runway:',
            'INFO:runway:Environment "test" was determined from the '
            'current git branch or parent directory.',
            'INFO:runway:If this is not the environment name, update '
            'the branch/folder name or set an override value via the '
            'DEPLOY_ENVIRONMENT environment variable', 'INFO:runway:'
        ]

        with self.assertLogs(LOGGER, logging.INFO) as logs:
            context.echo_detected_environment()

        self.assertEqual(logs.output, expected)
예제 #4
0
    def test_echo_detected_environment_from_env(self):
        """Environment helper note when DEPLOY_ENVIRONMENT is set."""
        if sys.version_info[0] < 3:
            return  # this test method was not added until 3.4

        context = Context(env_name='test',
                          env_region='us-east-1',
                          env_root='./',
                          env_vars={'DEPLOY_ENVIRONMENT': 'test'})
        expected = [
            'INFO:runway:',
            'INFO:runway:Environment "test" was determined from the '
            'DEPLOY_ENVIRONMENT environment variable.',
            'INFO:runway:If this is not correct, update the value (or '
            'unset it to fall back to the name of the current git '
            'branch or parent directory).', 'INFO:runway:'
        ]

        with self.assertLogs(LOGGER, logging.INFO) as logs:
            context.echo_detected_environment()

        self.assertEqual(logs.output, expected)
예제 #5
0
 def test_echo_detected_environment(self):
     """Test echo_detected_environment."""
     mock_env = MagicMock()
     obj = Context(deploy_environment=mock_env)
     assert not obj.echo_detected_environment()
     mock_env.log_name.assert_called_once_with()