Example #1
0
    def test_secret_environment_variable(self):
        scw = Scaleway(name="https://example.net")

        responses.add(
            responses.GET,
            "https://example.net/registry/v1/regions/fr-par/images",
            json={},
            status=200,
        )
        resp = scw.registry.images.GET()

        self.assertIn("X-Auth-Token", resp.request.headers)
        self.assertEqual(resp.request.headers["X-Auth-Token"],
                         "this-is-a-test-key")
Example #2
0
    def test_token_arg(self):
        scw = Scaleway(name="https://example.net", token="this-is-a-test-key")

        responses.add(
            responses.GET,
            "https://example.net/k8s/v1/regions/fr-par/clusters",
            json={},
            status=200,
        )
        resp = scw.k8s.clusters.GET()

        self.assertIn("X-Auth-Token", resp.request.headers)
        self.assertEqual(resp.request.headers["X-Auth-Token"],
                         "this-is-a-test-key")
Example #3
0
 def test_api_version(self):
     scw = Scaleway(version="v99")
     self.assertEqual(
         "https://api.scaleway.com/instance/v99/zones/fr-par-1/servers",
         str(scw.instance.servers),
     )
Example #4
0
 def test_default_zone_environment_variable(self):
     scw = Scaleway()
     self.assertEqual(
         "https://api.scaleway.com/instance/v1/zones/test-region-2/servers",
         str(scw.instance.servers),
     )
Example #5
0
 def test_zone_arg(self):
     scw = Scaleway(zone="test-region-3")
     self.assertEqual(
         "https://api.scaleway.com/instance/v1/zones/test-region-3/servers",
         str(scw.instance.servers),
     )
Example #6
0
 def test_version_and_region_only_added_once(self):
     scw = Scaleway()
     self.assertEqual(
         "https://api.scaleway.com/lbs/v1/regions/fr-par/lbs",
         str(scw.lbs.lbs),
     )
Example #7
0
 def test_api_name(self):
     scw = Scaleway(name="https://example.net/api")
     self.assertEqual(
         "https://example.net/api/rdb/v1/regions/fr-par/backups",
         str(scw.rdb.backups),
     )
Example #8
0
 def test_iot_beta(self):
     scw = Scaleway()
     self.assertEqual(
         "https://api.scaleway.com/iot/v1beta1/regions/fr-par/hubs",
         str(scw.iot.hubs),
     )
Example #9
0
 def test_region_environment_variable(self):
     scw = Scaleway()
     self.assertEqual(
         "https://api.scaleway.com/lbs/v1/regions/test-region/ips",
         str(scw.lbs.ips))
Example #10
0
 def test_default_zone(self):
     scw = Scaleway(region="test-region")
     self.assertEqual(
         "https://api.scaleway.com/baremetal/v1/zones/test-region-1/servers",
         str(scw.baremetal.servers),
     )
Example #11
0
 def test_api_version_environment_variable(self):
     scw = Scaleway()
     self.assertEqual(
         "https://api.scaleway.com/baremetal/v100/zones/fr-par-1/servers",
         str(scw.baremetal.servers),
     )