Exemple #1
0
    def test_find_dirs_second_passing(self):
        notpassing = [
            augeasparser.AugeasDirectiveNode(name="notpassing",
                                             ancestor=self.block,
                                             filepath="/path/to/whatever",
                                             metadata=self.metadata)
        ]
        passing = [
            augeasparser.AugeasDirectiveNode(name=assertions.PASS,
                                             ancestor=self.block,
                                             filepath=assertions.PASS,
                                             metadata=self.metadata)
        ]
        find_dirs_primary = mock.MagicMock(return_value=notpassing)
        find_dirs_secondary = mock.MagicMock(return_value=passing)
        self.block.primary.find_directives = find_dirs_primary
        self.block.secondary.find_directives = find_dirs_secondary

        directives = self.block.find_directives("something")
        for directive in directives:
            try:
                assertions.assertEqual(directive.primary, directive.secondary)
            except AssertionError:  # pragma: no cover
                self.fail("Assertion should have passed")
            self.assertFalse(assertions.isPassDirective(directive.primary))
            self.assertTrue(assertions.isPassDirective(directive.secondary))
Exemple #2
0
    def test_find_blocks_second_passing(self):
        youshallnotpass = [
            augeasparser.AugeasBlockNode(name="notpassing",
                                         ancestor=self.block,
                                         filepath="/path/to/whatever",
                                         metadata=self.metadata)
        ]
        youshallpass = [
            augeasparser.AugeasBlockNode(name=assertions.PASS,
                                         ancestor=self.block,
                                         filepath=assertions.PASS,
                                         metadata=self.metadata)
        ]
        find_blocks_primary = mock.MagicMock(return_value=youshallnotpass)
        find_blocks_secondary = mock.MagicMock(return_value=youshallpass)
        self.block.primary.find_blocks = find_blocks_primary
        self.block.secondary.find_blocks = find_blocks_secondary

        blocks = self.block.find_blocks("something")
        for block in blocks:
            try:
                assertions.assertEqual(block.primary, block.secondary)
            except AssertionError:  # pragma: no cover
                self.fail("Assertion should have passed")
            self.assertFalse(assertions.isPassDirective(block.primary))
            self.assertTrue(assertions.isPassDirective(block.secondary))