@@ -2340,9 +2340,9 @@ def test_get_media(self):
2340
2340
self .assertEqual (b"standing in for media" , response )
2341
2341
2342
2342
2343
- if HAS_UNIVERSE :
2344
2343
2345
- class Universe (unittest .TestCase ):
2344
+ class Universe (unittest .TestCase ):
2345
+ if HAS_UNIVERSE :
2346
2346
def test_validate_credentials_with_no_client_options (self ):
2347
2347
http = build_http ()
2348
2348
discovery = read_datafile ("zoo.json" )
@@ -2501,169 +2501,169 @@ def test_validate_credentials_with_already_validated_credentials(self):
2501
2501
# Calling service._validate_credentials() again returns service.credentials_validated.
2502
2502
assert service ._validate_credentials ()
2503
2503
2504
- def test_validate_credentials_before_api_request_success (self ):
2505
- fake_universe = "foo.com"
2506
- credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2507
- credentials .universe_domain = fake_universe
2508
- discovery = read_datafile ("tasks.json" )
2509
- tasks = build_from_document (
2510
- discovery ,
2511
- credentials = credentials ,
2512
- client_options = google .api_core .client_options .ClientOptions (
2513
- universe_domain = fake_universe
2514
- ),
2515
- )
2504
+ def test_validate_credentials_before_api_request_success (self ):
2505
+ fake_universe = "foo.com"
2506
+ credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2507
+ credentials .universe_domain = fake_universe
2508
+ discovery = read_datafile ("tasks.json" )
2509
+ tasks = build_from_document (
2510
+ discovery ,
2511
+ credentials = credentials ,
2512
+ client_options = google .api_core .client_options .ClientOptions (
2513
+ universe_domain = fake_universe
2514
+ ),
2515
+ )
2516
2516
2517
- tasklists = tasks .tasklists ()
2518
- request = tasklists .list ()
2517
+ tasklists = tasks .tasklists ()
2518
+ request = tasklists .list ()
2519
2519
2520
- # Check that credentials are indeed verified before request.
2521
- assert tasklists ._validate_credentials ()
2520
+ # Check that credentials are indeed verified before request.
2521
+ assert tasklists ._validate_credentials ()
2522
2522
2523
- def test_validate_credentials_before_api_request_failure (self ):
2524
- fake_universe = "foo.com"
2525
- credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2526
- credentials .universe_domain = fake_universe
2527
- discovery = read_datafile ("tasks.json" )
2528
- tasks = build_from_document (
2529
- discovery ,
2530
- credentials = credentials ,
2531
- client_options = google .api_core .client_options .ClientOptions (
2532
- universe_domain = universe .DEFAULT_UNIVERSE
2533
- ),
2534
- )
2523
+ def test_validate_credentials_before_api_request_failure (self ):
2524
+ fake_universe = "foo.com"
2525
+ credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2526
+ credentials .universe_domain = fake_universe
2527
+ discovery = read_datafile ("tasks.json" )
2528
+ tasks = build_from_document (
2529
+ discovery ,
2530
+ credentials = credentials ,
2531
+ client_options = google .api_core .client_options .ClientOptions (
2532
+ universe_domain = universe .DEFAULT_UNIVERSE
2533
+ ),
2534
+ )
2535
2535
2536
- # Check that credentials are verified before request.
2537
- with self .assertRaises (universe .UniverseMismatchError ):
2538
- request = tasks .tasklists ().list ()
2536
+ # Check that credentials are verified before request.
2537
+ with self .assertRaises (universe .UniverseMismatchError ):
2538
+ request = tasks .tasklists ().list ()
2539
2539
2540
- def test_validate_credentials_before_another_universe_api_request_failure (self ):
2541
- fake_universe = "foo.com"
2542
- credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2543
- credentials .universe_domain = fake_universe
2544
- another_fake_universe = "bar.com"
2545
- discovery = read_datafile ("tasks.json" )
2540
+ def test_validate_credentials_before_another_universe_api_request_failure (self ):
2541
+ fake_universe = "foo.com"
2542
+ credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2543
+ credentials .universe_domain = fake_universe
2544
+ another_fake_universe = "bar.com"
2545
+ discovery = read_datafile ("tasks.json" )
2546
+ tasks = build_from_document (
2547
+ discovery ,
2548
+ credentials = credentials ,
2549
+ client_options = google .api_core .client_options .ClientOptions (
2550
+ universe_domain = another_fake_universe
2551
+ ),
2552
+ )
2553
+
2554
+ # Check that credentials are verified before request.
2555
+ with self .assertRaises (universe .UniverseMismatchError ):
2556
+ request = tasks .tasklists ().list ()
2557
+
2558
+ def test_client_options_with_empty_universe (self ):
2559
+ fake_universe = "foo.com"
2560
+ credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2561
+ discovery = read_datafile ("tasks.json" )
2562
+
2563
+ with self .assertRaises (universe .EmptyUniverseError ):
2546
2564
tasks = build_from_document (
2547
2565
discovery ,
2548
2566
credentials = credentials ,
2549
2567
client_options = google .api_core .client_options .ClientOptions (
2550
- universe_domain = another_fake_universe
2568
+ universe_domain = ""
2551
2569
),
2552
2570
)
2553
2571
2554
- # Check that credentials are verified before request.
2555
- with self .assertRaises (universe .UniverseMismatchError ):
2556
- request = tasks .tasklists ().list ()
2557
-
2558
- def test_client_options_with_empty_universe (self ):
2559
- fake_universe = "foo.com"
2560
- credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2561
- discovery = read_datafile ("tasks.json" )
2572
+ def test_client_options_universe_configured_with_mtls (self ):
2573
+ fake_universe = "foo.com"
2574
+ discovery = read_datafile ("tasks.json" )
2562
2575
2563
- with self .assertRaises (universe .EmptyUniverseError ):
2576
+ with self .assertRaises (MutualTLSChannelError ):
2577
+ with mock .patch .dict (
2578
+ "os.environ" , {"GOOGLE_API_USE_MTLS_ENDPOINT" : "always" }
2579
+ ):
2564
2580
tasks = build_from_document (
2565
2581
discovery ,
2566
- credentials = credentials ,
2567
2582
client_options = google .api_core .client_options .ClientOptions (
2568
- universe_domain = ""
2583
+ universe_domain = fake_universe
2569
2584
),
2570
2585
)
2571
2586
2572
- def test_client_options_universe_configured_with_mtls (self ):
2573
- fake_universe = "foo.com"
2574
- discovery = read_datafile ("tasks.json" )
2575
-
2576
- with self .assertRaises (MutualTLSChannelError ):
2577
- with mock .patch .dict (
2578
- "os.environ" , {"GOOGLE_API_USE_MTLS_ENDPOINT" : "always" }
2579
- ):
2580
- tasks = build_from_document (
2581
- discovery ,
2582
- client_options = google .api_core .client_options .ClientOptions (
2583
- universe_domain = fake_universe
2584
- ),
2585
- )
2586
-
2587
- def test_client_options_universe_configured_with_api_override (self ):
2588
- fake_universe = "foo.com"
2589
- fake_api_endpoint = "https://www.bar.com/"
2590
- credentials = mock .Mock (universe_domain = fake_universe )
2591
- discovery = read_datafile ("tasks.json" )
2592
-
2593
- tasks = build_from_document (
2594
- discovery ,
2595
- credentials = credentials ,
2596
- client_options = google .api_core .client_options .ClientOptions (
2597
- api_endpoint = fake_api_endpoint , universe_domain = fake_universe
2598
- ),
2599
- )
2600
-
2601
- assert tasks ._baseUrl == fake_api_endpoint
2602
-
2603
- def test_universe_env_var_configured_empty (self ):
2604
- credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2605
- discovery = read_datafile ("tasks.json" )
2606
-
2607
- with self .assertRaises (universe .EmptyUniverseError ):
2608
- with mock .patch .dict (
2609
- "os.environ" , {"GOOGLE_CLOUD_UNIVERSE_DOMAIN" : "" }
2610
- ):
2611
- tasks = build_from_document (
2612
- discovery ,
2613
- credentials = credentials ,
2614
- )
2587
+ def test_client_options_universe_configured_with_api_override (self ):
2588
+ fake_universe = "foo.com"
2589
+ fake_api_endpoint = "https://www.bar.com/"
2590
+ credentials = mock .Mock (universe_domain = fake_universe )
2591
+ discovery = read_datafile ("tasks.json" )
2615
2592
2616
- def test_universe_env_var_configured_with_mtls (self ):
2617
- fake_universe = "foo.com"
2618
- discovery = read_datafile ("tasks.json" )
2593
+ tasks = build_from_document (
2594
+ discovery ,
2595
+ credentials = credentials ,
2596
+ client_options = google .api_core .client_options .ClientOptions (
2597
+ api_endpoint = fake_api_endpoint , universe_domain = fake_universe
2598
+ ),
2599
+ )
2619
2600
2620
- with self .assertRaises (MutualTLSChannelError ):
2621
- with mock .patch .dict (
2622
- "os.environ" ,
2623
- {
2624
- "GOOGLE_API_USE_MTLS_ENDPOINT" : "always" ,
2625
- "GOOGLE_CLOUD_UNIVERSE_DOMAIN" : fake_universe ,
2626
- },
2627
- ):
2628
- tasks = build_from_document (discovery )
2601
+ assert tasks ._baseUrl == fake_api_endpoint
2629
2602
2630
- def test_universe_env_var_configured_with_api_override (self ):
2631
- fake_universe = "foo.com"
2632
- fake_api_endpoint = "https://www.bar.com/"
2633
- credentials = mock .Mock (universe_domain = fake_universe )
2634
- discovery = read_datafile ("tasks.json" )
2603
+ def test_universe_env_var_configured_empty (self ):
2604
+ credentials = mock .Mock (spec = google .auth .credentials .Credentials )
2605
+ discovery = read_datafile ("tasks.json" )
2635
2606
2607
+ with self .assertRaises (universe .EmptyUniverseError ):
2636
2608
with mock .patch .dict (
2637
- "os.environ" , {"GOOGLE_CLOUD_UNIVERSE_DOMAIN" : fake_universe }
2609
+ "os.environ" , {"GOOGLE_CLOUD_UNIVERSE_DOMAIN" : "" }
2638
2610
):
2639
2611
tasks = build_from_document (
2640
2612
discovery ,
2641
2613
credentials = credentials ,
2642
- client_options = google .api_core .client_options .ClientOptions (
2643
- api_endpoint = fake_api_endpoint
2644
- ),
2645
2614
)
2646
2615
2647
- assert tasks ._baseUrl == fake_api_endpoint
2648
-
2649
- def test_universe_env_var_configured_with_client_options_universe (self ):
2650
- fake_universe = "foo.com"
2651
- another_fake_universe = "bar.com"
2652
- credentials = mock .Mock (universe_domain = fake_universe )
2653
- discovery = read_datafile ("tasks.json" )
2616
+ def test_universe_env_var_configured_with_mtls (self ):
2617
+ fake_universe = "foo.com"
2618
+ discovery = read_datafile ("tasks.json" )
2654
2619
2620
+ with self .assertRaises (MutualTLSChannelError ):
2655
2621
with mock .patch .dict (
2656
- "os.environ" , {"GOOGLE_CLOUD_UNIVERSE_DOMAIN" : another_fake_universe }
2622
+ "os.environ" ,
2623
+ {
2624
+ "GOOGLE_API_USE_MTLS_ENDPOINT" : "always" ,
2625
+ "GOOGLE_CLOUD_UNIVERSE_DOMAIN" : fake_universe ,
2626
+ },
2657
2627
):
2658
- tasks = build_from_document (
2659
- discovery ,
2660
- credentials = credentials ,
2661
- client_options = google .api_core .client_options .ClientOptions (
2662
- universe_domain = fake_universe
2663
- ),
2664
- )
2628
+ tasks = build_from_document (discovery )
2629
+
2630
+ def test_universe_env_var_configured_with_api_override (self ):
2631
+ fake_universe = "foo.com"
2632
+ fake_api_endpoint = "https://www.bar.com/"
2633
+ credentials = mock .Mock (universe_domain = fake_universe )
2634
+ discovery = read_datafile ("tasks.json" )
2635
+
2636
+ with mock .patch .dict (
2637
+ "os.environ" , {"GOOGLE_CLOUD_UNIVERSE_DOMAIN" : fake_universe }
2638
+ ):
2639
+ tasks = build_from_document (
2640
+ discovery ,
2641
+ credentials = credentials ,
2642
+ client_options = google .api_core .client_options .ClientOptions (
2643
+ api_endpoint = fake_api_endpoint
2644
+ ),
2645
+ )
2646
+
2647
+ assert tasks ._baseUrl == fake_api_endpoint
2648
+
2649
+ def test_universe_env_var_configured_with_client_options_universe (self ):
2650
+ fake_universe = "foo.com"
2651
+ another_fake_universe = "bar.com"
2652
+ credentials = mock .Mock (universe_domain = fake_universe )
2653
+ discovery = read_datafile ("tasks.json" )
2654
+
2655
+ with mock .patch .dict (
2656
+ "os.environ" , {"GOOGLE_CLOUD_UNIVERSE_DOMAIN" : another_fake_universe }
2657
+ ):
2658
+ tasks = build_from_document (
2659
+ discovery ,
2660
+ credentials = credentials ,
2661
+ client_options = google .api_core .client_options .ClientOptions (
2662
+ universe_domain = fake_universe
2663
+ ),
2664
+ )
2665
2665
2666
- assert tasks ._universe_domain == fake_universe
2666
+ assert tasks ._universe_domain == fake_universe
2667
2667
2668
2668
2669
2669
if __name__ == "__main__" :
0 commit comments