File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 runs-on : ubuntu-latest
2020 steps :
2121 - run : ' echo "No build required" '
22+
23+ lint :
24+ runs-on : ubuntu-latest
25+ steps :
26+ - run : ' echo "No build required" '
Original file line number Diff line number Diff line change 1919
2020import django
2121from django .db import connections
22-
2322from django .db .backends .utils import CursorDebugWrapper
2423from google .cloud .sqlcommenter import add_sql_comment
2524from google .cloud .sqlcommenter .opencensus import get_opencensus_values
Original file line number Diff line number Diff line change 1717import django
1818from django .db import connection , connections
1919from django .http import HttpRequest
20- from django .test import TestCase , override_settings , modify_settings
20+ from django .test import TestCase , modify_settings , override_settings
2121from django .urls import resolve , reverse
22- from google .cloud .sqlcommenter .django .middleware import SqlCommenter , QueryWrapper
22+ from google .cloud .sqlcommenter .django .middleware import (
23+ QueryWrapper , SqlCommenter ,
24+ )
2325
2426from ..compat import mock
2527from ..opencensus_mock import mock_opencensus_tracer
3032# Adding the middleware twice in modify_settings
3133# doesn't work. The middleware is only used once
3234# if used in modify_settings
35+
36+
3337class TestMiddleware :
3438 def __init__ (self , get_response ):
3539 self .get_response = get_response
@@ -38,10 +42,12 @@ def __call__(self, request):
3842 with connection .execute_wrapper (QueryWrapper (request )):
3943 return self .get_response (request )
4044
45+
4146# Query log only active if DEBUG=True.
4247@override_settings (DEBUG = True )
4348class Tests (TestCase ):
4449 databases = '__all__'
50+
4551 @staticmethod
4652 def get_request (path ):
4753 request = HttpRequest ()
Original file line number Diff line number Diff line change 22
33from fastapi import FastAPI , status
44from fastapi .responses import JSONResponse
5+ from google .cloud .sqlcommenter .fastapi import (
6+ SQLCommenterMiddleware , get_fastapi_info ,
7+ )
58from starlette .exceptions import HTTPException as StarletteHTTPException
69
7- from google .cloud .sqlcommenter .fastapi import SQLCommenterMiddleware , get_fastapi_info
8-
910app = FastAPI (title = "SQLCommenter" )
1011
1112app .add_middleware (SQLCommenterMiddleware )
Original file line number Diff line number Diff line change 1818
1919import fastapi
2020import pytest
21- from starlette .testclient import TestClient
22-
2321from google .cloud .sqlcommenter .fastapi import get_fastapi_info
22+ from starlette .testclient import TestClient
2423
2524from .app import app
2625
Original file line number Diff line number Diff line change @@ -27,10 +27,10 @@ def test_end_comment_escaping(self):
2727 self .assertEqual ("Select 1 /*a='%%2A/abc'*/" , add_sql_comment ("Select 1" , a = '*/abc' ))
2828
2929 def test_bytes (self ):
30- self .assertIn ("Select 1 /*a='%%2A/abc'*/" , add_sql_comment ("Select 1" ,a = b'*/abc' ))
30+ self .assertIn ("Select 1 /*a='%%2A/abc'*/" , add_sql_comment ("Select 1" , a = b'*/abc' ))
3131
3232 def test_url_quoting (self ):
33- self .assertIn ("Select 1 /*foo='bar%%2Cbaz'*/" , add_sql_comment ("Select 1" ,foo = 'bar,baz' ))
33+ self .assertIn ("Select 1 /*foo='bar%%2Cbaz'*/" , add_sql_comment ("Select 1" , foo = 'bar,baz' ))
3434
3535 def test_sql_with_semicolon (self ):
36- self .assertIn ("Select 1 /*foo='bar%%2Cbaz'*/;" , add_sql_comment ("Select 1;" ,foo = 'bar,baz' ))
36+ self .assertIn ("Select 1 /*foo='bar%%2Cbaz'*/;" , add_sql_comment ("Select 1;" , foo = 'bar,baz' ))
You can’t perform that action at this time.
0 commit comments