Beispiel #1
0
 def test_create_store(self, create_database, StoqlibStore):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 password='******',
                                 port='12345')
     store = settings.create_store()
     self.assertEqual(create_database.call_count, 1)
     uri = create_database.call_args[0][0]
     self.assertEquals(
         str(uri),
         'postgres://*****:*****@address:12345/stoq?isolation=read-committed')
     self.assertEqual(StoqlibStore.call_count, 1)
     self.failUnless(store)
Beispiel #2
0
 def test_create_store(self, create_database, StoqlibStore):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 password='******',
                                 port='12345')
     store = settings.create_store()
     self.assertEqual(create_database.call_count, 1)
     uri = create_database.call_args[0][0]
     self.assertEqual(
         str(uri),
         'postgres://*****:*****@address:12345/stoq?isolation=read-committed'
     )
     self.assertEqual(StoqlibStore.call_count, 1)
     self.assertTrue(store)
Beispiel #3
0
 def test_create_store_localhost(self, test_local_database, create_database,
                                 StoqlibStore):
     # FIXME: This should not be necessary, instead DatabaseSettings should
     #        do if address is not None to differenciate between '' and None
     os.environ.pop('PGHOST', None)
     test_local_database.return_value = ('/var/run/postgresql', '5432')
     settings = DatabaseSettings(address='', username='******')
     store = settings.create_store()
     self.assertEqual(create_database.call_count, 1)
     test_local_database.called_once_with()
     uri = create_database.call_args[0][0]
     self.assertEqual(uri.host, '/var/run/postgresql')
     self.assertEqual(uri.port, 5432)
     self.assertEqual(
         str(uri),
         'postgres://username@%2Fvar%2Frun%2Fpostgresql:5432/stoq?isolation=read-committed'
     )
     self.assertEqual(StoqlibStore.call_count, 1)
     self.assertTrue(store)
Beispiel #4
0
 def test_create_store_localhost(self, test_local_database,
                                 create_database, StoqlibStore):
     # FIXME: This should not be necessary, instead DatabaseSettings should
     #        do if address is not None to differenciate between '' and None
     os.environ.pop('PGHOST', None)
     test_local_database.return_value = ('/var/run/postgresql', '5432')
     settings = DatabaseSettings(address='',
                                 username='******')
     store = settings.create_store()
     self.assertEqual(create_database.call_count, 1)
     test_local_database.called_once_with()
     uri = create_database.call_args[0][0]
     self.assertEquals(uri.host, '/var/run/postgresql')
     self.assertEquals(uri.port, 5432)
     self.assertEquals(
         str(uri),
         'postgres://username@%2Fvar%2Frun%2Fpostgresql:5432/stoq?isolation=read-committed')
     self.assertEqual(StoqlibStore.call_count, 1)
     self.failUnless(store)