Exemple #1
0
 def test_execute_query_should_not_accept_dict_params(self):
     with pytest.raises(DBAPIError):
         ahjo.execute_query(
             self.engine,
             query=
             'SELECT * FROM store.Clients WHERE country = ? AND zip_code = ?',
             variables={
                 'country': 'Finland',
                 'zip_code': '00180'
             })
Exemple #2
0
 def test_execute_query_should_autocommit(self):
     ahjo.execute_query(
         self.engine,
         query=
         "INSERT INTO store.Clients (name, phone) VALUES ('Test_1', 112), ('Test_2', 112)",
         isolation_level='AUTOCOMMIT'  # default
     )
     query = "SELECT name, phone FROM store.Clients WHERE phone = 112"
     result = self.engine.execute(query).fetchall()
     assert result[0] == ('Test_1', '112')
     assert result[1] == ('Test_2', '112')
Exemple #3
0
 def test_execute_query_should_accept_tuple_params(self):
     result = ahjo.execute_query(
         self.engine,
         query=
         'SELECT * FROM store.Clients WHERE country = ? AND zip_code = ?',
         variables=('Finland', '00180'))
     assert result
Exemple #4
0
 def test_execute_query_should_raise_error_from_proc(self):
     with pytest.raises(ProgrammingError):
         ahjo.execute_query(self.engine, query='EXEC store.RaiseError')
Exemple #5
0
 def test_execute_query_should_not_return_rows_from_proc(self):
     result = ahjo.execute_query(self.engine,
                                 query='EXEC store.UpdateClients')
     assert result == []
Exemple #6
0
 def test_execute_query_should_return_headers(self):
     result = ahjo.execute_query(self.engine,
                                 query='SELECT name FROM store.Clients',
                                 include_headers=True)
     assert result[0][0] == 'name'
Exemple #7
0
 def test_execute_query_should_not_return_headers(self):
     result = ahjo.execute_query(self.engine,
                                 query='SELECT name FROM store.Clients')
     assert result[0][0] != 'name'
Exemple #8
0
 def test_execute_query_should_not_accept_str_param(self):
     with pytest.raises(DBAPIError):
         ahjo.execute_query(
             self.engine,
             query='SELECT * FROM store.Clients WHERE country = ?',
             variables='Finland')
Exemple #9
0
 def test_execute_query_should_accept_list_params(self):
     result = ahjo.execute_query(
         self.engine,
         query='SELECT * FROM store.Clients WHERE country = ?',
         variables=['Finland'])
     assert result
Exemple #10
0
 def test_execute_query_should_return_rows(self):
     result = ahjo.execute_query(self.engine,
                                 query='SELECT * FROM store.Clients')
     assert result