Exemplo n.º 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'
             })
Exemplo n.º 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')
Exemplo n.º 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
Exemplo n.º 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')
Exemplo n.º 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 == []
Exemplo n.º 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'
Exemplo n.º 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'
Exemplo n.º 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')
Exemplo n.º 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
Exemplo n.º 10
0
 def test_execute_query_should_return_rows(self):
     result = ahjo.execute_query(self.engine,
                                 query='SELECT * FROM store.Clients')
     assert result