4
4
# license that can be found in the LICENSE file or at
5
5
# https://developers.google.com/open-source/licenses/bsd
6
6
7
- from django . db . utils import DatabaseError
7
+ from base64 import b64encode
8
8
from datetime import timedelta
9
- from tests .unit .django_spanner .simple_test import SpannerSimpleTestClass
10
9
from decimal import Decimal
10
+ from django .conf import settings
11
+ from django .core .management .color import no_style
12
+ from django .db .utils import DatabaseError
13
+ from google .cloud .spanner_dbapi .types import DateStr
14
+ from tests .unit .django_spanner .simple_test import SpannerSimpleTestClass
15
+ import uuid
11
16
12
17
13
18
class TestOperations (SpannerSimpleTestClass ):
@@ -29,8 +34,6 @@ def test_bulk_batch_size(self):
29
34
)
30
35
31
36
def test_sql_flush (self ):
32
- from django .core .management .color import no_style
33
-
34
37
self .assertEqual (
35
38
self .db_operations .sql_flush (
36
39
style = no_style (), tables = ["Table1" , "Table2" ]
@@ -39,15 +42,11 @@ def test_sql_flush(self):
39
42
)
40
43
41
44
def test_sql_flush_empty_table_list (self ):
42
- from django .core .management .color import no_style
43
-
44
45
self .assertEqual (
45
46
self .db_operations .sql_flush (style = no_style (), tables = []), [],
46
47
)
47
48
48
49
def test_adapt_datefield_value (self ):
49
- from google .cloud .spanner_dbapi .types import DateStr
50
-
51
50
self .assertIsInstance (
52
51
self .db_operations .adapt_datefield_value ("dummy_date" ), DateStr ,
53
52
)
@@ -69,8 +68,6 @@ def test_adapt_decimalfield_value_none(self):
69
68
)
70
69
71
70
def test_convert_binaryfield_value (self ):
72
- from base64 import b64encode
73
-
74
71
self .assertEqual (
75
72
self .db_operations .convert_binaryfield_value (
76
73
value = b64encode (b"abc" ), expression = None , connection = None
@@ -96,8 +93,6 @@ def test_adapt_timefield_value_none(self):
96
93
)
97
94
98
95
def test_convert_uuidfield_value (self ):
99
- import uuid
100
-
101
96
uuid_obj = uuid .uuid4 ()
102
97
self .assertEqual (
103
98
self .db_operations .convert_uuidfield_value (
@@ -126,8 +121,6 @@ def test_date_extract_sql_lookup_type_dayofweek(self):
126
121
)
127
122
128
123
def test_datetime_extract_sql (self ):
129
- from django .conf import settings
130
-
131
124
settings .USE_TZ = True
132
125
self .assertEqual (
133
126
self .db_operations .datetime_extract_sql (
@@ -137,8 +130,6 @@ def test_datetime_extract_sql(self):
137
130
)
138
131
139
132
def test_datetime_extract_sql_use_tz_false (self ):
140
- from django .conf import settings
141
-
142
133
settings .USE_TZ = False
143
134
self .assertEqual (
144
135
self .db_operations .datetime_extract_sql (
@@ -167,17 +158,13 @@ def test_datetime_cast_date_sql(self):
167
158
)
168
159
169
160
def test_datetime_cast_time_sql (self ):
170
- from django .conf import settings
171
-
172
161
settings .USE_TZ = True
173
162
self .assertEqual (
174
163
self .db_operations .datetime_cast_time_sql ("dummy_field" , "IST" ),
175
164
"TIMESTAMP(FORMAT_TIMESTAMP('%Y-%m-%d %R:%E9S %Z', dummy_field, 'IST'))" ,
176
165
)
177
166
178
167
def test_datetime_cast_time_sql_use_tz_false (self ):
179
- from django .conf import settings
180
-
181
168
settings .USE_TZ = False
182
169
self .assertEqual (
183
170
self .db_operations .datetime_cast_time_sql ("dummy_field" , "IST" ),
0 commit comments