diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 21218dbcf..d76cc64c6 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,6 +15,7 @@ jobs: - scaleway-core - scaleway - scaleway-async + python-version: ['3.10' ,'3.11', '3.12', '3.13'] defaults: run: working-directory: ${{ matrix.lib }} @@ -23,7 +24,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Install poetry run: | pip install poetry @@ -49,7 +50,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Install poetry run: | pip install poetry @@ -75,7 +76,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Install poetry run: | pip install poetry @@ -88,34 +89,35 @@ jobs: - name: Check linting run: poetry run ruff check . --ignore E721 --ignore F541 - # tests: - # runs-on: ubuntu-latest - # strategy: - # matrix: - # lib: - # - scaleway-core - # - scaleway - # - scaleway-async - # defaults: - # run: - # working-directory: ${{ matrix.lib }} - # steps: - # - uses: actions/checkout@v4 - # - name: Set up Python - # uses: actions/setup-python@v5 - # with: - # python-version: "3.10" - # - name: Install poetry - # run: | - # pip install poetry - # poetry --version - # - name: Install dependencies and library - # run: poetry install - # - name: Run tests - # run: poetry run python -m unittest discover -s tests -v - # env: - # SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }} - # SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }} - # SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }} - # SCW_DEFAULT_REGION: ${{ secrets.SCW_DEFAULT_REGION }} - # SCW_DEFAULT_ZONE: ${{ secrets.SCW_DEFAULT_ZONE }} + tests: + runs-on: ubuntu-latest + strategy: + matrix: + lib: + - scaleway-core + - scaleway + - scaleway-async + defaults: + run: + working-directory: ${{ matrix.lib }} + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install poetry + run: | + pip install poetry + poetry --version + - name: Install dependencies and library + run: poetry install + - name: Run tests + env: + SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }} + SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }} + SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }} + SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }} + SCW_DEFAULT_REGION: ${{ secrets.SCW_DEFAULT_REGION }} + run: poetry run python -m unittest discover -s tests -v + diff --git a/scaleway-async/tests/test_test_v1.py b/scaleway-async/tests/test_test_v1.py index 7e7fdaeaf..8b1b8a939 100644 --- a/scaleway-async/tests/test_test_v1.py +++ b/scaleway-async/tests/test_test_v1.py @@ -8,6 +8,7 @@ from scaleway_async.test.v1 import EyeColors, Human, HumanStatus, TestV1API +@unittest.skip("API test is not deployed") class TestTestV1(unittest.IsolatedAsyncioTestCase): async def asyncSetUp(self) -> None: client = Client.from_config_file_and_env() diff --git a/scaleway/tests/test_instance.py b/scaleway/tests/test_instance.py index 6059a4115..b6762d088 100644 --- a/scaleway/tests/test_instance.py +++ b/scaleway/tests/test_instance.py @@ -1,5 +1,3 @@ -import logging -import sys from typing import List import unittest import uuid @@ -11,10 +9,6 @@ from scaleway.instance.v1.types import Server, VolumeServerTemplate from scaleway.block.v1alpha1.types import Volume, CreateVolumeRequestFromEmpty -logger = logging.getLogger() -logger.level = logging.DEBUG -stream_handler = logging.StreamHandler(sys.stdout) -logger.addHandler(stream_handler) server_name = f"test-sdk-python-{uuid.uuid4().hex[:6]}" max_retry = 10 @@ -24,10 +18,11 @@ zone = "fr-par-1" +@unittest.skip("Skipping this test temporarily") class TestE2EServerCreation(unittest.TestCase): def setUp(self) -> None: self.zone = zone - self.client = Client.from_config_file_and_env() + self.client = Client.from_env() self.instanceAPI = InstanceV1API(self.client, bypass_validation=True) self.blockAPI = BlockV1Alpha1API(self.client, bypass_validation=True) self._server = None @@ -38,14 +33,11 @@ def tearDown(self) -> None: self.instanceAPI.detach_server_volume( server_id=self._server.id, volume_id=volume.id ) - logger.info("✅ Volume {volume.id} has been detach") self.blockAPI.delete_volume(volume_id=volume.id) - logger.info("✅ Volume {volume.id} has been deleted") if self._server: self.instanceAPI.delete_server(zone=self.zone, server_id=self._server.id) - logger.info(f"🗑️ Deleted server: {self._server.id}") def wait_test_instance_server(self, server_id): interval = interval @@ -55,7 +47,6 @@ def wait_test_instance_server(self, server_id): s = self.instanceAPI.get_server(zone=self.zone, server_id=server_id) if s.state == "running": - logger.info(f"✅ Server {server_id} is running.") break time.sleep(interval) @@ -76,7 +67,6 @@ def create_test_instance_server(self) -> Server: dynamic_ip_required=True, volumes=volume, ) - logger.info(f"✅ Created server: {server.id}") self._server = server.server @@ -91,7 +81,6 @@ def create_test_from_empty_volume(self, number) -> List[Volume]: volume = self.blockAPI.create_volume( from_empty=CreateVolumeRequestFromEmpty(size=10), ) - logger.info("✅ Created server: {volume.id}") self.blockAPI.wait_for_volume(volume_id=volume.id, zone=self.zone) @@ -110,7 +99,6 @@ def test_attach_aditionnal_volume(self): self.assertIsNotNone(additional_volume.id) self.assertEqual(additional_volume.size, 10) - logger.info(f"✅ Volume created with ID: {additional_volume.id}") self.instanceAPI.attach_server_volume( server_id=server.id, volume_id=additional_volume.id @@ -118,14 +106,9 @@ def test_attach_aditionnal_volume(self): self.blockAPI.wait_for_volume(volume_id=additional_volume.id, zone=self.zone) - logger.info(f"🔗 Attached volume {additional_volume.id} to server {server.id}") - updated_server = self.instanceAPI.get_server( zone=self.zone, server_id=server.id ) attached_volumes = updated_server.volumes or {} attached_volume_ids = [v.volume.id for v in attached_volumes.values()] self.assertIn(additional_volume.id, attached_volume_ids) - logger.info( - f"✅ Volume {additional_volume.id} is attached to server {server.id}" - ) diff --git a/scaleway/tests/test_test_v1_marshalling.py b/scaleway/tests/test_test_v1_marshalling.py index bf7571442..93f7c53fe 100644 --- a/scaleway/tests/test_test_v1_marshalling.py +++ b/scaleway/tests/test_test_v1_marshalling.py @@ -105,11 +105,13 @@ def _assert_raw_and_unmarshalled_human( raw["updated_at"], ) + @unittest.skip("API test is not deployed") def test_unmarshal_Human(self) -> None: data = _mock_human_raw() human = unmarshal_Human(data) self._assert_raw_and_unmarshalled_human(data, human) + @unittest.skip("API test is not deployed") def test_unmarshal_ListHumansResponse(self) -> None: humans = [_mock_human_raw() for _ in range(10)] data = { @@ -164,6 +166,7 @@ def _assert_create_human_request_and_raw( self.assertEqual(request.name, raw["name"]) self.assertEqual(request.shoe_size, raw["shoe_size"]) + @unittest.skip("API test is not deployed") def test_marshal_CreateHumanRequest(self) -> None: request = _mock_create_human_request() raw = marshal_CreateHumanRequest(request, utils.random_profile_defaults()) diff --git a/scaleway/tests/test_total_count_legacy.py b/scaleway/tests/test_total_count_legacy.py index c49f025f3..3b22ceec1 100644 --- a/scaleway/tests/test_total_count_legacy.py +++ b/scaleway/tests/test_total_count_legacy.py @@ -12,7 +12,7 @@ class TestTotalCountLegacy(unittest.TestCase): def setUp(self) -> None: - self.client = Client() + self.client = Client.from_env() self.instance_api = InstanceV1API(self.client, bypass_validation=True) def test_list_servers_type(self): diff --git a/scaleway/tests/test_vpc.py b/scaleway/tests/test_vpc.py new file mode 100644 index 000000000..87380f077 --- /dev/null +++ b/scaleway/tests/test_vpc.py @@ -0,0 +1,91 @@ +import unittest +from scaleway.vpc.v2 import VpcV2API +from scaleway_core.api import ScalewayException +from scaleway_core.client import Client +from scaleway_core.utils import random_name + +region = "fr-par" +tags = ["sdk-python", "regression-test"] +created_pn_count = 5 +created_vpc_count = 1 + + +class TestScalewayVPCV2(unittest.TestCase): + @classmethod + def setUpClass(self): + self.client = Client.from_env() + self.vpcAPI = VpcV2API(self.client) + self.project_id = self.client.default_project_id + self.region = region + self._pns_to_cleanup = [] + + self._vpc = self.vpcAPI.create_vpc( + enable_routing=True, + region=self.region, + project_id=self.project_id, + name=random_name("vpc-test-sdk-python"), + ) + + @classmethod + def tearDownClass(self): + for pn in self._pns_to_cleanup: + self.vpcAPI.delete_private_network(private_network_id=pn.id) + + if self._vpc is not None: + self.vpcAPI.delete_vpc(vpc_id=self._vpc.id, region=self.region) + + def test_delete_vpc(self): + vpc = self.vpcAPI.create_vpc( + enable_routing=True, + region=self.region, + project_id=self.project_id, + name=random_name("vpc-test-sdk-python"), + ) + + self.assertIsNotNone(vpc.id) + self.assertEqual(vpc.region, self.region) + + self.vpcAPI.delete_vpc(vpc_id=vpc.id) + + with self.assertRaises(ScalewayException): + self.vpcAPI.get_vpc(vpc_id=vpc.id) + + def test_list_vpcs(self): + vpcs = self.vpcAPI.list_vp_cs(region=self.region) + self.assertIsInstance(vpcs.vpcs, list) + self.assertGreaterEqual(vpcs.total_count, created_vpc_count) + + def test_create_private_network(self): + for i in range(created_pn_count): + pn = self.vpcAPI.create_private_network( + vpc_id=self._vpc.id, + default_route_propagation_enabled=True, + project_id=self.project_id, + name=random_name(f"sdk-python-pn-{i}"), + ) + self._pns_to_cleanup.append(pn) + + self.assertEqual(pn.vpc_id, self._vpc.id) + + def test_list_private_network(self): + networks = self.vpcAPI.list_private_networks(region=self.region) + self.assertIsInstance(networks.private_networks, list) + self.assertGreaterEqual(networks.total_count, created_pn_count) + + def test_get_vpc(self): + vpc = self.vpcAPI.get_vpc(vpc_id=self._vpc.id, region=self.region) + + self.assertIsNotNone(vpc) + self.assertEqual(self._vpc.id, vpc.id) + + def test_update_vpc(self): + vpc = self.vpcAPI.update_vpc(vpc_id=self._vpc.id, tags=tags) + + self.assertEqual(vpc.tags, tags) + self.assertEqual(self._vpc.id, vpc.id) + + def test_list_vpc_all(self): + vpcs = self.vpcAPI.list_vp_cs_all() + + self.assertIsInstance(vpcs, list) + self.assertGreaterEqual(len(vpcs), created_vpc_count)