예제 #1
0
 def test_get_store_dsn(self):
     settings = DatabaseSettings(address='address',
                                 username='******')
     self.assertEqual(settings.get_store_uri(),
                      'postgres://username@address:5432/stoq')
     self.assertEqual(settings.get_store_dsn(),
                      'dbname=stoq host=address port=5432 user=username')
예제 #2
0
 def test_get_tool_args(self):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 password='******',
                                 port='12345')
     self.assertEqual(settings.get_tool_args(),
                      ['-U', 'username', '-h', 'address', '-p', '12345'])
예제 #3
0
 def test_get_store_dsn_port(self):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 port='12345')
     self.assertEqual(settings.get_store_uri(),
                      'postgres://username@address:12345/stoq')
     self.assertEqual(settings.get_store_dsn(),
                      'dbname=stoq host=address port=12345 user=username')
예제 #4
0
 def test_get_store_dsn_port(self):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 port='12345')
     self.assertEqual(settings.get_store_uri(),
                      'postgres://username@address:12345/stoq')
     self.assertEqual(settings.get_store_dsn(),
                      'dbname=stoq host=address port=12345 user=username')
예제 #5
0
 def test_get_command_line_arguments(self):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 password='******',
                                 port='12345')
     self.assertEqual(settings.get_command_line_arguments(), [
         '-d', 'stoq', '-H', 'address', '-p', '12345', '-u', 'username',
         '-w', 'password'
     ])
예제 #6
0
 def test_get_store_dsn_password(self):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 password='******')
     self.assertEquals(settings.get_store_uri(),
                       'postgres://*****:*****@address:5432/stoq')
     self.assertEquals(
         settings.get_store_dsn(),
         'dbname=stoq host=address port=5432 user=username password=password')
예제 #7
0
 def test_get_tool_args(self):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 password='******',
                                 port='12345')
     self.assertEquals(settings.get_tool_args(),
                       ['-U', 'username',
                        '-h', 'address',
                        '-p', '12345'])
예제 #8
0
 def test_get_store_dsn_password(self):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 password='******')
     self.assertEqual(settings.get_store_uri(),
                      'postgres://*****:*****@address:5432/stoq')
     self.assertEqual(
         settings.get_store_dsn(),
         'dbname=stoq host=address port=5432 user=username password=password'
     )
예제 #9
0
 def test_create_super_store(self, create_database, StoqlibStore):
     settings = DatabaseSettings(address='localhost',
                                 username='******')
     store = settings.create_super_store()
     self.assertEqual(create_database.call_count, 1)
     uri = create_database.call_args[0][0]
     self.assertEquals(
         str(uri),
         'postgres://username@localhost:5432/postgres?isolation=read-committed')
     self.assertEqual(StoqlibStore.call_count, 1)
     self.failUnless(store)
예제 #10
0
 def test_get_command_line_arguments(self):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 password='******',
                                 port='12345')
     self.assertEquals(settings.get_command_line_arguments(),
                       ['-d', 'stoq',
                        '-H', 'address',
                        '-p', '12345',
                        '-u', 'username',
                        '-w', 'password'])
예제 #11
0
 def test_create_super_store(self, create_database, StoqlibStore):
     settings = DatabaseSettings(address='localhost', username='******')
     store = settings.create_super_store()
     self.assertEqual(create_database.call_count, 1)
     uri = create_database.call_args[0][0]
     self.assertEqual(
         str(uri),
         'postgres://username@localhost:5432/postgres?isolation=read-committed'
     )
     self.assertEqual(StoqlibStore.call_count, 1)
     self.assertTrue(store)
예제 #12
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)
예제 #13
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)
예제 #14
0
    def test_get_store_dsn_no_host(self, tld):
        settings = DatabaseSettings(address='address',
                                    username='******')
        # Force address to be empty, just like when we connect using
        # the unix socket
        settings.address = ''

        tld.return_value = None
        with self.assertRaisesRegex(
                DatabaseError,
                "Could not find a database server on this computer"):
            settings.get_store_dsn()

        tld.return_value = ('<unix_socket>', 1234)
        self.assertEqual(settings.get_store_dsn(),
                         'dbname=stoq host=<unix_socket> port=1234 user=username')
예제 #15
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)
예제 #16
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)
예제 #17
0
    def create_wizard(self):
        options = mock.Mock()
        options.sqldebug = False
        options.verbose = False

        if self.settings is None:
            self.settings = DatabaseSettings(address=u'localhost',
                                             port=12345,
                                             dbname=u'dbname',
                                             username=u'username',
                                             password=u'password')

        self.settings.has_database = lambda: False
        self.config = self.fake.StoqConfig(self.settings)
        wizard = FirstTimeConfigWizard(options, self.config)
        return wizard
예제 #18
0
    def test_get_store_dsn_no_host(self, tld):
        settings = DatabaseSettings(address='address', username='******')
        # Force address to be empty, just like when we connect using
        # the unix socket
        settings.address = ''

        tld.return_value = None
        with self.assertRaisesRegex(
                DatabaseError,
                "Could not find a database server on this computer"):
            settings.get_store_dsn()

        tld.return_value = ('<unix_socket>', 1234)
        self.assertEqual(
            settings.get_store_dsn(),
            'dbname=stoq host=<unix_socket> port=1234 user=username')
예제 #19
0
 def test_get_store_dsn(self):
     settings = DatabaseSettings(address='address', username='******')
     self.assertEquals(settings.get_store_uri(),
                       'postgres://username@address:5432/stoq')
     self.assertEquals(settings.get_store_dsn(),
                       'dbname=stoq host=address port=5432 user=username')
예제 #20
0
 def test_get_store_dsn(self):
     settings = DatabaseSettings(address='address',
                                 username='******')
     self.assertEquals(settings.get_store_dsn(),
                       'postgres://username@address:5432/stoq')
예제 #21
0
 def test_get_store_dsn_password(self):
     settings = DatabaseSettings(address='address',
                                 username='******',
                                 password='******')
     self.assertEquals(settings.get_store_dsn(),
                       'postgres://*****:*****@address:5432/stoq')