Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3
digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe
4 changes: 3 additions & 1 deletion django_spanner/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,9 @@ def add_index(self, model, index):
"index": "|".join(index.fields),
}
with trace_call(
"CloudSpannerDjango.add_index", self.connection, trace_attributes,
"CloudSpannerDjango.add_index",
self.connection,
trace_attributes,
):
super().add_index(model, index)

Expand Down
12 changes: 6 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
master_doc = "index"

# General information about the project.
project = u"google-cloud-spanner-django"
copyright = u"2020, Google"
author = u"Google APIs"
project = "google-cloud-spanner-django"
copyright = "2020, Google"
author = "Google APIs"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -278,7 +278,7 @@
(
master_doc,
"django-google-spanner.tex",
u"Spanner Django Documentation",
"Spanner Django Documentation",
author,
"manual",
)
Expand Down Expand Up @@ -313,7 +313,7 @@
(
master_doc,
"django-google-spanner",
u"django-google-spanner Documentation",
"django-google-spanner Documentation",
[author],
1,
)
Expand All @@ -332,7 +332,7 @@
(
master_doc,
"django-google-spanner",
u"django-google-spanner Documentation",
"django-google-spanner Documentation",
author,
"django-google-spanner",
"django-google-spanner Library",
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import nox

BLACK_VERSION = "black==19.10b0"
BLACK_VERSION = "black==22.3.0"
BLACK_PATHS = [
"docs",
"django_spanner",
Expand Down
5 changes: 4 additions & 1 deletion tests/performance/django_spanner/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def __init__(self):
@measure_execution_time
def insert_one_row_with_fetch_after(self):
author_kent = Author(
id=2, first_name="Pete", last_name="Allison", rating="2.1",
id=2,
first_name="Pete",
last_name="Allison",
rating="2.1",
)
author_kent.save()
last_name = Author.objects.get(pk=author_kent.id).last_name
Expand Down
16 changes: 12 additions & 4 deletions tests/system/django_spanner/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ def test_insert_and_search_decimal_value(self):
Tests model object creation with Author model.
"""
author_kent = Author(
first_name="Arthur", last_name="Kent", rating=Decimal("4.1"),
first_name="Arthur",
last_name="Kent",
rating=Decimal("4.1"),
)
author_kent.save()
qs1 = Author.objects.filter(rating__gte=3).values("rating")
self.assertValuesEqual(
qs1, [Decimal("4.1")], self.rating_transform,
qs1,
[Decimal("4.1")],
self.rating_transform,
)
# Delete data from Author table.
Author.objects.all().delete()
Expand Down Expand Up @@ -94,7 +98,9 @@ def test_decimal_update(self):
Tests decimal object update.
"""
author_kent = Author(
first_name="Arthur", last_name="Kent", rating=Decimal("4.1"),
first_name="Arthur",
last_name="Kent",
rating=Decimal("4.1"),
)
author_kent.save()
author_kent.rating = Decimal("4.2")
Expand All @@ -103,7 +109,9 @@ def test_decimal_update(self):
"rating"
)
self.assertValuesEqual(
qs1, [Decimal("4.2")], self.rating_transform,
qs1,
[Decimal("4.2")],
self.rating_transform,
)
# Delete data from Author table.
Author.objects.all().delete()
4 changes: 3 additions & 1 deletion tests/system/django_spanner/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def test_insert_and_fetch_value(self):
Inserting data into the model and retrieving it.
"""
author_kent = Author(
first_name="Arthur", last_name="Kent", rating=Decimal("4.1"),
first_name="Arthur",
last_name="Kent",
rating=Decimal("4.1"),
)
author_kent.save()
qs1 = Author.objects.all().values("first_name", "last_name")
Expand Down
11 changes: 8 additions & 3 deletions tests/unit/django_spanner/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def test_cot(self):
"""
Tests cot function on a column.
"""
q1 = Author.objects.values("num").annotate(num_cot=Cot("num"),)
q1 = Author.objects.values("num").annotate(
num_cot=Cot("num"),
)
compiler = SQLCompiler(q1.query, self.connection, "default")
sql_query, params = compiler.query.as_sql(compiler, self.connection)
self.assertEqual(
Expand All @@ -95,7 +97,9 @@ def test_degrees(self):
"""
Tests degrees function on a column.
"""
q1 = Author.objects.values("num").annotate(num_degrees=Degrees("num"),)
q1 = Author.objects.values("num").annotate(
num_degrees=Degrees("num"),
)
compiler = SQLCompiler(q1.query, self.connection, "default")
sql_query, params = compiler.query.as_sql(compiler, self.connection)
self.assertEqual(
Expand Down Expand Up @@ -188,7 +192,8 @@ def test_pi(self):
+ "= (3.141592653589793)"
)
self.assertEqual(
sql_query, expected_sql,
sql_query,
expected_sql,
)
self.assertEqual(params, ())

Expand Down
7 changes: 5 additions & 2 deletions tests/unit/django_spanner/test_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ def run_sql_in_snapshot(*args, **kwargs):
cursor=cursor, table_name="Table_1"
)
self.assertEqual(
primary_key, "PK_column",
primary_key,
"PK_column",
)

def test_get_primary_key_column_returns_none(self):
Expand All @@ -174,7 +175,9 @@ def run_sql_in_snapshot(*args, **kwargs):
primary_key = db_introspection.get_primary_key_column(
cursor=cursor, table_name="Table_1"
)
self.assertIsNone(primary_key,)
self.assertIsNone(
primary_key,
)

def test_get_constraints(self):
"""
Expand Down
19 changes: 14 additions & 5 deletions tests/unit/django_spanner/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ def test_sql_flush(self):

def test_sql_flush_empty_table_list(self):
self.assertEqual(
self.db_operations.sql_flush(style=no_style(), tables=[]), [],
self.db_operations.sql_flush(style=no_style(), tables=[]),
[],
)

def test_adapt_datefield_value(self):
self.assertIsInstance(
self.db_operations.adapt_datefield_value("dummy_date"), DateStr,
self.db_operations.adapt_datefield_value("dummy_date"),
DateStr,
)

def test_adapt_datefield_value_none(self):
Expand Down Expand Up @@ -204,7 +206,8 @@ def test_combine_expression_bit_extention(self):

def test_combine_expression_multiply(self):
self.assertEqual(
self.db_operations.combine_expression("*", ["10", "2"]), "10 * 2",
self.db_operations.combine_expression("*", ["10", "2"]),
"10 * 2",
)

def test_combine_duration_expression_add(self):
Expand Down Expand Up @@ -235,10 +238,16 @@ def test_combine_duration_expression_database_error(self):

def test_lookup_cast_match_lookup_type(self):
self.assertEqual(
self.db_operations.lookup_cast("contains",), "CAST(%s AS STRING)",
self.db_operations.lookup_cast(
"contains",
),
"CAST(%s AS STRING)",
)

def test_lookup_cast_unmatched_lookup_type(self):
self.assertEqual(
self.db_operations.lookup_cast("dummy",), "%s",
self.db_operations.lookup_cast(
"dummy",
),
"%s",
)
17 changes: 13 additions & 4 deletions tests/unit/django_spanner/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ def constraint_names(*args, **kwargs):
)
self.assertSpanAttributes(
"CloudSpannerDjango.delete_model",
attributes=dict(BASE_ATTRIBUTES, model_name="tests_author",),
attributes=dict(
BASE_ATTRIBUTES,
model_name="tests_author",
),
span=span_list[1],
)

Expand Down Expand Up @@ -168,7 +171,9 @@ def test_remove_field(self):
self.assertSpanAttributes(
"CloudSpannerDjango.remove_field",
attributes=dict(
BASE_ATTRIBUTES, model_name="tests_author", field="num",
BASE_ATTRIBUTES,
model_name="tests_author",
field="num",
),
span=span_list[0],
)
Expand Down Expand Up @@ -216,7 +221,9 @@ def constraint_names(*args, **kwargs):
self.assertSpanAttributes(
"CloudSpannerDjango.remove_field",
attributes=dict(
BASE_ATTRIBUTES, model_name="tests_author", field="num",
BASE_ATTRIBUTES,
model_name="tests_author",
field="num",
),
span=span_list[1],
)
Expand Down Expand Up @@ -266,7 +273,9 @@ def test_column_add_index(self):
self.assertSpanAttributes(
"CloudSpannerDjango.add_index",
attributes=dict(
BASE_ATTRIBUTES, model_name="tests_author", index="num",
BASE_ATTRIBUTES,
model_name="tests_author",
index="num",
),
span=span_list[0],
)
Expand Down