Exemple #1
0
def location_is_ec2():
    """
    Return True if running on EC2.

    For this check to work, you need to be running within supervisord or
    bin/with_ec2_env.
    """
    return env_flag('EC2', False)
Exemple #2
0
def location_is_ec2():
    """
    Return True if running on EC2.

    For this check to work, you need to be running within supervisord or
    bin/with_ec2_env.
    """
    return env_flag('EC2', False)
Exemple #3
0
    def get_bool(env_mapping: Enum) -> bool:
        """
        returns the boolean associated with the input environment mapping

        Args:
            env_mapping (Enum): environment mapping to fetch

        Returns:
            bool: bool associated with the environment mapping
        """
        if not EnvManager._all_vars_checked:
            raise ValueError(
                EnvManager._env_mappings_not_checked_error_message)
        assert isinstance(env_mapping, Enum)

        EnvManager._check_env_mapping_exists(env_mapping)

        return env_flag(env_mapping.name)
Exemple #4
0
 def test_that_env_flag_for_unset_returns_false(self):
     env_var = str(uuid.uuid4())
     self.assertIsNone(os.environ.get(env_var))
     self.assertFalse(env_flag(env_var))
Exemple #5
0
 def test_that_env_flag_for_any_capitalized_true_returns_true(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = 'tRue'
     self.assertEquals(os.environ.get(env_var), 'tRue')
     self.assertTrue(env_flag(env_var))
Exemple #6
0
 def test_that_env_flag_for_1_returns_true(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = '1'
     self.assertEquals(os.environ.get(env_var), '1')
     self.assertTrue(env_flag(env_var))
Exemple #7
0
 def test_that_env_flag_for_0_does_not_return_default(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = '0'
     self.assertEquals(os.environ.get(env_var), '0')
     self.assertFalse(env_flag(env_var, True))
Exemple #8
0
 def test_that_env_flag_for_0_returns_false(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = '0'
     self.assertEquals(os.environ.get(env_var), '0')
     self.assertFalse(env_flag(env_var))
Exemple #9
0
 def test_that_env_flag_for_string_with_spaces_returns_default(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = '     '
     self.assertEquals(os.environ.get(env_var), '     ')
     self.assertFalse(env_flag(env_var, False))
     self.assertTrue(env_flag(env_var, True))
Exemple #10
0
 def test_that_env_flag_for_unset_returns_false(self):
     env_var = str(uuid.uuid4())
     self.assertIsNone(os.environ.get(env_var))
     self.assertFalse(env_flag(env_var))
Exemple #11
0
 def test_that_env_flag_for_any_capitalized_true_returns_true(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = 'tRue'
     self.assertEquals(os.environ.get(env_var), 'tRue')
     self.assertTrue(env_flag(env_var))
Exemple #12
0
 def test_that_env_flag_for_1_returns_true(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = '1'
     self.assertEquals(os.environ.get(env_var), '1')
     self.assertTrue(env_flag(env_var))
Exemple #13
0
 def test_that_env_flag_for_0_does_not_return_default(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = '0'
     self.assertEquals(os.environ.get(env_var), '0')
     self.assertFalse(env_flag(env_var, True))
Exemple #14
0
 def test_that_env_flag_for_0_returns_false(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = '0'
     self.assertEquals(os.environ.get(env_var), '0')
     self.assertFalse(env_flag(env_var))
Exemple #15
0
 def test_that_env_flag_for_string_with_spaces_returns_default(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = '     '
     self.assertEquals(os.environ.get(env_var), '     ')
     self.assertFalse(env_flag(env_var, False))
     self.assertTrue(env_flag(env_var, True))
Exemple #16
0
 def test_that_env_flag_for_empty_string_returns_false(self):
     env_var = str(uuid.uuid4())
     os.environ[env_var] = ''
     self.assertEqual(os.environ.get(env_var), '')
     self.assertFalse(env_flag(env_var))