Skip to content

Instantly share code, notes, and snippets.

@prabdeb
Last active June 16, 2020 08:49
Show Gist options
  • Save prabdeb/5c7ded094b536324b32bc1f02de58804 to your computer and use it in GitHub Desktop.
Save prabdeb/5c7ded094b536324b32bc1f02de58804 to your computer and use it in GitHub Desktop.
Unit Testing with Azure SQL Database
class TestMethods(unittest.TestCase):
@patch('pyodbc.connect')
def test_myanalysis_analysis(self,
mock_pyodbc_connect):
'''Test Case 1: Test analysis in MyAnalysis'''
mock_cursor = mock_pyodbc_connect.return_value.cursor.return_value
mock_cursor.description = [
("col_a", "1"), ("col_b", "2"), ("col_c", "3"), ("col_d", "4"), ("col_e", "4")]
mock_cursor.fetchall.return_value = [
("a", "b", "c", "d", "e")]
myanalysis_obj = MyAnalysis()
analysis_data = myanalysis_obj.analysis()
self.assertEqual(len(analysis_data), 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment