@@ -47,16 +47,58 @@ def test_valid_credentials_object(self):
47
47
assert config .client_secret == "test_client_secret"
48
48
assert config .scopes == ["https://www.googleapis.com/auth/calendar" ]
49
49
50
- def test_valid_client_id_secret_pair (self ):
51
- """Test that providing client ID and secret without credentials works.
50
+ def test_valid_client_id_secret_pair_default_scope (self ):
51
+ """Test that providing client ID and secret with default scope works.
52
52
53
53
This tests the scenario where users want to create new OAuth credentials
54
- from scratch using their application's client ID and secret.
54
+ from scratch using their application's client ID and secret and does not
55
+ specify the scopes explicitly.
55
56
"""
56
57
config = BigQueryCredentialsConfig (
57
58
client_id = "test_client_id" ,
58
59
client_secret = "test_client_secret" ,
59
- scopes = ["https://www.googleapis.com/auth/bigquery" ],
60
+ )
61
+
62
+ assert config .credentials is None
63
+ assert config .client_id == "test_client_id"
64
+ assert config .client_secret == "test_client_secret"
65
+ assert config .scopes == ["https://www.googleapis.com/auth/bigquery" ]
66
+
67
+ def test_valid_client_id_secret_pair_w_scope (self ):
68
+ """Test that providing client ID and secret with explicit scopes works.
69
+
70
+ This tests the scenario where users want to create new OAuth credentials
71
+ from scratch using their application's client ID and secret and does specify
72
+ the scopes explicitly.
73
+ """
74
+ config = BigQueryCredentialsConfig (
75
+ client_id = "test_client_id" ,
76
+ client_secret = "test_client_secret" ,
77
+ scopes = [
78
+ "https://www.googleapis.com/auth/bigquery" ,
79
+ "https://www.googleapis.com/auth/drive" ,
80
+ ],
81
+ )
82
+
83
+ assert config .credentials is None
84
+ assert config .client_id == "test_client_id"
85
+ assert config .client_secret == "test_client_secret"
86
+ assert config .scopes == [
87
+ "https://www.googleapis.com/auth/bigquery" ,
88
+ "https://www.googleapis.com/auth/drive" ,
89
+ ]
90
+
91
+ def test_valid_client_id_secret_pair_w_empty_scope (self ):
92
+ """Test that providing client ID and secret with empty scope works.
93
+
94
+ This tests the corner case scenario where users want to create new OAuth
95
+ credentials from scratch using their application's client ID and secret but
96
+ specifies empty scope, in which case the default BQ scope is used.
97
+ """
98
+ config = BigQueryCredentialsConfig (
99
+ client_id = "test_client_id" ,
100
+ client_secret = "test_client_secret" ,
101
+ scopes = [],
60
102
)
61
103
62
104
assert config .credentials is None
@@ -73,7 +115,7 @@ def test_missing_client_secret_raises_error(self):
73
115
with pytest .raises (
74
116
ValueError ,
75
117
match = (
76
- "Must provide either credentials or client_id abd client_secret"
118
+ "Must provide either credentials or client_id and client_secret"
77
119
" pair"
78
120
),
79
121
):
@@ -84,7 +126,7 @@ def test_missing_client_id_raises_error(self):
84
126
with pytest .raises (
85
127
ValueError ,
86
128
match = (
87
- "Must provide either credentials or client_id abd client_secret"
129
+ "Must provide either credentials or client_id and client_secret"
88
130
" pair"
89
131
),
90
132
):
@@ -99,7 +141,7 @@ def test_empty_configuration_raises_error(self):
99
141
with pytest .raises (
100
142
ValueError ,
101
143
match = (
102
- "Must provide either credentials or client_id abd client_secret"
144
+ "Must provide either credentials or client_id and client_secret"
103
145
" pair"
104
146
),
105
147
):
0 commit comments