Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 19, 2023
1 parent c97146e commit e583d54
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
11 changes: 7 additions & 4 deletions example/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ async def async_home(request):
async def async_db(request):
user_count = await User.objects.acount()

return await sync_to_async(render)(request, "async_db.html", {"user_count": user_count})
return await sync_to_async(render)(
request, "async_db.html", {"user_count": user_count}
)


async def async_db_concurrent(request):
# Do database queries concurrently
(user_count, _) = await asyncio.gather(
User.objects.acount(),
User.objects.filter(username="test").acount()
User.objects.acount(), User.objects.filter(username="test").acount()
)

return await sync_to_async(render)(request, "async_db.html", {"user_count": user_count})
return await sync_to_async(render)(
request, "async_db.html", {"user_count": user_count}
)
1 change: 0 additions & 1 deletion tests/panels/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ async def test_recording_concurrent_async(self):
# ensure the stacktrace is populated
self.assertTrue(len(query["stacktrace"]) > 0)


@unittest.skipUnless(
connection.vendor == "postgresql", "Test valid only on PostgreSQL"
)
Expand Down
25 changes: 15 additions & 10 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,21 @@ def test_data_gone(self):

def test_sql_page(self):
response = self.client.get("/execute_sql/")
self.assertEqual(len(response.toolbar.get_panel_by_id("SQLPanel").get_stats()["queries"]), 1)
self.assertEqual(
len(response.toolbar.get_panel_by_id("SQLPanel").get_stats()["queries"]), 1
)

def test_async_sql_page(self):
response = self.client.get("/async_execute_sql/")
self.assertEqual(len(response.toolbar.get_panel_by_id("SQLPanel").get_stats()["queries"]), 1)
self.assertEqual(
len(response.toolbar.get_panel_by_id("SQLPanel").get_stats()["queries"]), 1
)

def test_concurrent_async_sql_page(self):
response = self.client.get("/async_execute_sql_concurrently/")
self.assertEqual(len(response.toolbar.get_panel_by_id("SQLPanel").get_stats()["queries"]), 2)
self.assertEqual(
len(response.toolbar.get_panel_by_id("SQLPanel").get_stats()["queries"]), 2
)


@override_settings(DEBUG=True)
Expand Down Expand Up @@ -764,27 +770,26 @@ def test_toolbar_language_will_render_to_locale_when_set_both(self):

def test_async_sql_action(self):
self.get("/async_execute_sql/")
sql_panel = self.selenium.find_element(By.ID, "SQLPanel")
debug_window = self.selenium.find_element(By.ID, "djDebugWindow")
self.selenium.find_element(By.ID, "SQLPanel")
self.selenium.find_element(By.ID, "djDebugWindow")

# Click to show the SQL panel
self.selenium.find_element(By.CLASS_NAME, "SQLPanel").click()

# SQL panel loads
button = self.wait.until(
self.wait.until(
EC.visibility_of_element_located((By.CSS_SELECTOR, ".remoteCall"))
)


def test_concurrent_async_sql_action(self):
self.get("/async_execute_sql_concurrently/")
sql_panel = self.selenium.find_element(By.ID, "SQLPanel")
debug_window = self.selenium.find_element(By.ID, "djDebugWindow")
self.selenium.find_element(By.ID, "SQLPanel")
self.selenium.find_element(By.ID, "djDebugWindow")

# Click to show the SQL panel
self.selenium.find_element(By.CLASS_NAME, "SQLPanel").click()

# SQL panel loads
button = self.wait.until(
self.wait.until(
EC.visibility_of_element_located((By.CSS_SELECTOR, ".remoteCall"))
)
1 change: 0 additions & 1 deletion tests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ async def async_execute_sql_concurrently(request):
return render(request, "base.html")



def regular_view(request, title):
return render(request, "basic.html", {"title": title})

Expand Down

0 comments on commit e583d54

Please sign in to comment.