Ejemplo n.º 1
0
    def test_get_step_by_name(self):
        """Test getting step by name. """
        names = ["a", "b", "c"]
        layout = Layout(steps=[Step(name=name) for name in names])
        self.assertEqual(layout.get_step_by_name("b").name, "b")

        with self.assertRaises(securesystemslib.exceptions.FormatError):
            layout.get_step_by_name(None)
Ejemplo n.º 2
0
    def test_remove_step_by_name(self):
        """Test removing step by name. """
        names = ["a", "b", "c"]
        layout = Layout(steps=[Step(name=name) for name in names])

        self.assertEqual(len(layout.steps), 3)
        self.assertTrue("b" in layout.get_step_name_list())
        # Items are only removed if they exist
        for _ in range(2):
            layout.remove_step_by_name("b")
            self.assertEqual(len(layout.steps), 2)
            self.assertTrue("b" not in layout.get_step_name_list())

        with self.assertRaises(securesystemslib.exceptions.FormatError):
            layout.get_step_by_name([])