def test_components(self, duthosts, enum_rand_one_per_hwsku_hostname,
                        localhost, platform_api_conn):
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]

        try:
            num_components = int(chassis.get_num_components(platform_api_conn))
        except:
            pytest.fail("num_components is not an integer")
        else:
            if num_components == 0:
                pytest.skip("No components found on device")

        if duthost.facts.get("chassis"):
            expected_num_components = len(
                duthost.facts.get("chassis").get('components'))
            pytest_assert(
                num_components == expected_num_components,
                "Number of components ({}) does not match expected number ({})"
                .format(num_components, expected_num_components))

        component_list = chassis.get_all_components(platform_api_conn)
        pytest_assert(component_list is not None,
                      "Failed to retrieve components")
        pytest_assert(
            isinstance(component_list, list)
            and len(component_list) == num_components,
            "Components appear to be incorrect")

        for i in range(num_components):
            component = chassis.get_component(platform_api_conn, i)
            self.expect(component and component == component_list[i],
                        "Component {} is incorrect".format(i))
        self.assert_expectations()
    def test_components(self, duthost, localhost, platform_api_conn):
        try:
            num_components = int(chassis.get_num_components(platform_api_conn))
        except:
            pytest.fail("num_components is not an integer")

        if self.chassis_facts:
            expected_num_components = len(self.chassis_facts.get('components'))
            pytest_assert(
                num_components == expected_num_components,
                "Number of components ({}) does not match expected number ({})"
                .format(num_components, expected_num_components))

        component_list = chassis.get_all_components(platform_api_conn)
        pytest_assert(component_list is not None,
                      "Failed to retrieve components")
        pytest_assert(
            isinstance(component_list, list)
            and len(component_list) == num_components,
            "Components appear to be incorrect")

        for i in range(num_components):
            component = chassis.get_component(platform_api_conn, i)
            self.expect(component and component == component_list[i],
                        "Component {} is incorrect".format(i))
        self.assert_expectations()
Exemple #3
0
    def test_components(self, duthost, localhost, platform_api_conn):
        # TODO: Ensure the number of components and that the returned list is correct for this platform
        try:
            num_components = int(chassis.get_num_components(platform_api_conn))
        except:
            pytest.fail("num_components is not an integer")

        component_list = chassis.get_all_components(platform_api_conn)
        pytest_assert(component_list is not None,
                      "Failed to retrieve components")
        pytest_assert(
            isinstance(component_list, list)
            and len(component_list) == num_components,
            "Components appear to be incorrect")

        for i in range(num_components):
            component = chassis.get_component(platform_api_conn, i)
            self.expect(component and component == component_list[i],
                        "Component {} is incorrect".format(i))
        self.assert_expectations()