예제 #1
0
    def test_set(self):
        dutreq = ResourceRequirements(self.simple_testreqs)
        dutreq.set("test_key", "test_val")
        self.assertEqual(dutreq._requirements["test_key"], "test_val")
        # Test override
        dutreq.set("test_key", "test_val2")
        self.assertEqual(dutreq._requirements["test_key"], "test_val2")

        # test tags merging. Also a test for set_tag(tags=stuff)
        dutreq.set("tags", {"test": False, "test2": True})
        self.assertEqual(dutreq._requirements["tags"], {"test": False, "test2": True})
        dutreq.set("tags", {"test2": False})
        self.assertEqual(dutreq._requirements["tags"], {"test": False, "test2": False})
예제 #2
0
    def __generate_indexed_requirements(dut_count, basekeys, requirements):
        """
        Generate indexed requirements from general requirements.

        :param dut_count: Amount of duts
        :param basekeys: base keys as dict
        :param requirements: requirements
        :return: Indexed requirements as dict.
        """
        dut_requirements = []
        for i in range(1, dut_count + 1):
            dut_requirement = ResourceRequirements(basekeys.copy())
            if i in requirements["duts"]:
                for k in requirements["duts"][i]:
                    dut_requirement.set(k, requirements["duts"][i][k])
            elif str(i) in requirements["duts"]:
                i = str(i)
                for k in requirements["duts"][i]:
                    dut_requirement.set(k, requirements["duts"][i][k])
            dut_requirements.append(dut_requirement)
        return dut_requirements