def test_env_timestamp_required_and_default_are_mutually_exclusive(): """ test the mutual exclusivity of the `required` and `default` keywords """ assert "TEST_DATETIME_ENV_VARIABLE" not in os.environ with pytest.raises(ValueError): env_timestamp("TEST_DATETIME_ENV_VARIABLE", required=True, default="some-default")
def test_env_timestamp_required_and_default_are_mutually_exclusive(): """ test the mutual exclusivity of the `required` and `default` keywords """ assert 'TEST_DATETIME_ENV_VARIABLE' not in os.environ with pytest.raises(ValueError): env_timestamp('TEST_DATETIME_ENV_VARIABLE', required=True, default='some-default')
def test_with_utc_timestamp(monkeypatch): when_in = datetime.datetime.utcnow() timestamp = to_timestamp(when_in) monkeypatch.setenv("TEST_DATETIME_ENV_VARIABLE", repr(timestamp)) when_out = env_timestamp("TEST_DATETIME_ENV_VARIABLE") assert_datetimes_almost_equal(when_in, when_out)
def test_with_utc_timestamp(monkeypatch): when_in = datetime.datetime.utcnow() timestamp = to_timestamp(when_in) monkeypatch.setenv( 'TEST_DATETIME_ENV_VARIABLE', repr(timestamp), ) when_out = env_timestamp('TEST_DATETIME_ENV_VARIABLE') assert_datetimes_almost_equal(when_in, when_out)
def test_with_no_default(): assert "TEST_DATETIME_ENV_VARIABLE" not in os.environ with pytest.raises(ValueError): env_timestamp("TEST_DATETIME_ENV_VARIABLE")
def test_with_no_default(): assert 'TEST_DATETIME_ENV_VARIABLE' not in os.environ with pytest.raises(ValueError): env_timestamp('TEST_DATETIME_ENV_VARIABLE')