def test_get_default_value(self): """ Tests the case that the environment variable does not exists and the value is needed. """ expected = None actual = EnvironmentVariable("Hello,World").get_value() self.assertEqual(expected, actual) expected = True actual = EnvironmentVariable("Hello,World").get_value(default=True) self.assertEqual(expected, actual)
def test_set_value_wrong_type(self): """ Tests the case that we want to set a non string value. """ self.assertRaises(TypeError, lambda: EnvironmentVariable("TEST").set_value(1))
def test_name_does_not_exists(self): """ Tests the case that a name does not exist. """ expected = False actual = EnvironmentVariable("HELLO,WORLD").exists() self.assertEqual(expected, actual)
def test_get_value(self): """ Tests the case that the value is needed. """ environ["TEST"] = "Hello, World!" expected = "Hello, World!" actual = EnvironmentVariable("TEST").get_value() self.assertEqual(expected, actual)
def test_name_exists(self): """ Tests the case that a name exist. """ environ["TEST"] = "test" expected = True actual = EnvironmentVariable("TEST").exists() self.assertEqual(expected, actual)
def test_set_value(self): """ Tests the case the we want to set the value of an environment variable. """ expected_value = "Hello!" expected_output = True actual = EnvironmentVariable("TEST").set_value("Hello!") self.assertEqual(expected_output, actual) self.assertEqual(expected_value, environ["TEST"])