def test_lock_timeout_is_zero_by_default(self): self.assertTrue(Factory.POSTGRES_LOCK_TIMEOUT not in os.environ) self.factory = Factory("TestCase", os.environ) self.assertEqual(self.factory.datastore.lock_timeout, 0) os.environ[Factory.POSTGRES_LOCK_TIMEOUT] = "" self.factory = Factory("TestCase", os.environ) self.assertEqual(self.factory.datastore.lock_timeout, 0)
def test_idle_in_transaction_session_timeout_is_zero_by_default(self): self.assertTrue(Factory.POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT not in os.environ) self.factory = Factory("TestCase", os.environ) self.assertEqual( self.factory.datastore.idle_in_transaction_session_timeout, 0) os.environ[Factory.POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT] = "" self.factory = Factory("TestCase", os.environ) self.assertEqual( self.factory.datastore.idle_in_transaction_session_timeout, 0)
def test_environment_error_raised_when_lock_timeout_not_a_float(self): os.environ[Factory.POSTGRES_LOCK_TIMEOUT] = "abc" with self.assertRaises(EnvironmentError) as cm: self.factory = Factory("TestCase", os.environ) self.assertEqual( cm.exception.args[0], "Postgres environment value for key 'POSTGRES_LOCK_TIMEOUT' " "is invalid. If set, a float or empty string is expected: 'abc'", )
def test_environment_error_raised_when_conn_max_age_not_a_float(self): os.environ[Factory.POSTGRES_CONN_MAX_AGE] = "abc" with self.assertRaises(EnvironmentError) as cm: self.factory = Factory("TestCase", os.environ) self.assertEqual( cm.exception.args[0], "Postgres environment value for key 'POSTGRES_CONN_MAX_AGE' " "is invalid. If set, a float or empty string is expected: 'abc'", )
def test_environment_error_raised_when_idle_in_transaction_session_timeout_not_a_float( self, ): os.environ[ Factory.POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT] = "abc" with self.assertRaises(EnvironmentError) as cm: self.factory = Factory("TestCase", os.environ) self.assertEqual( cm.exception.args[0], "Postgres environment value for key " "'POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT' " "is invalid. If set, a float or empty string is expected: 'abc'", )
def test_pre_ping_on(self): os.environ[Factory.POSTGRES_PRE_PING] = "on" self.factory = Factory("TestCase", os.environ) self.assertEqual(self.factory.datastore.pre_ping, True)
def test_pre_ping_off_by_default(self): self.factory = Factory("TestCase", os.environ) self.assertEqual(self.factory.datastore.pre_ping, False)
def test_idle_in_transaction_session_timeout_is_nonzero(self): os.environ[ Factory.POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT] = "1.234" self.factory = Factory("TestCase", os.environ) self.assertEqual( self.factory.datastore.idle_in_transaction_session_timeout, 1.234)
def test_lock_timeout_is_nonzero(self): os.environ[Factory.POSTGRES_LOCK_TIMEOUT] = "1.234" self.factory = Factory("TestCase", os.environ) self.assertEqual(self.factory.datastore.lock_timeout, 1.234)
def test_conn_max_age_is_set_to_number(self): os.environ[Factory.POSTGRES_CONN_MAX_AGE] = "0" self.factory = Factory("TestCase", os.environ) self.assertEqual(self.factory.datastore.conn_max_age, 0)
def test_conn_max_age_is_set_to_empty_string(self): os.environ[Factory.POSTGRES_CONN_MAX_AGE] = "" self.factory = Factory("TestCase", os.environ) self.assertEqual(self.factory.datastore.conn_max_age, None)