Exemplo n.º 1
0
    def test_build_pxe_config(self):
        args = {
                'deployment_id': 'aaa',
                'deployment_key': 'bbb',
                'deployment_iscsi_iqn': 'ccc',
                'deployment_aki_path': 'ddd',
                'deployment_ari_path': 'eee',
                'aki_path': 'fff',
                'ari_path': 'ggg',
            }
        config = pxe.build_pxe_config(**args)
        self.assertThat(config, matchers.StartsWith('default deploy'))

        # deploy bits are in the deploy section
        start = config.index('label deploy')
        end = config.index('label boot')
        self.assertThat(config[start:end], matchers.MatchesAll(
            matchers.Contains('kernel ddd'),
            matchers.Contains('initrd=eee'),
            matchers.Contains('deployment_id=aaa'),
            matchers.Contains('deployment_key=bbb'),
            matchers.Contains('iscsi_target_iqn=ccc'),
            matchers.Not(matchers.Contains('kernel fff')),
            ))

        # boot bits are in the boot section
        start = config.index('label boot')
        self.assertThat(config[start:], matchers.MatchesAll(
            matchers.Contains('kernel fff'),
            matchers.Contains('initrd=ggg'),
            matchers.Not(matchers.Contains('kernel ddd')),
            ))
Exemplo n.º 2
0
 def match(self, matchee):
     checks = []
     checks.append(matchers.IsInstance(MultiCheck))
     checks.append(
         matchers.AfterPreprocessing(operator.attrgetter('strategy'),
                                     matchers.Is(self.strategy)))
     checks.append(
         matchers.AfterPreprocessing(
             operator.attrgetter('subchecks'),
             matchers.MatchesListwise(self.subchecks)))
     return matchers.MatchesAll(*checks).match(matchee)
Exemplo n.º 3
0
 def match(self, matchee):
     checks = []
     checks.append(matchers.IsInstance(FunctionCheck))
     checks.append(
         matchers.Annotate(
             "name doesn't match",
             matchers.AfterPreprocessing(operator.attrgetter('name'),
                                         matchers.Equals(self.name))))
     checks.append(
         matchers.Annotate(
             "info doesn't match",
             matchers.AfterPreprocessing(operator.attrgetter('info'),
                                         matchers.Equals(self.info))))
     checks.append(
         matchers.Annotate(
             "blocking doesn't match",
             matchers.AfterPreprocessing(operator.attrgetter('blocking'),
                                         matchers.Equals(self.blocking))))
     return matchers.MatchesAll(*checks).match(matchee)
Exemplo n.º 4
0
    def assertRaisesRegexp(self, exc_class, pattern, callable_obj, *args,
                           **kwargs):
        # TODO(harlowja): submit a pull/review request to testtools to add
        # this method to there codebase instead of having it exist in ours
        # since it really doesn't belong here.

        class ReRaiseOtherTypes(object):
            def match(self, matchee):
                if not issubclass(matchee[0], exc_class):
                    compat.reraise(*matchee)

        class CaptureMatchee(object):
            def match(self, matchee):
                self.matchee = matchee[1]

        capture = CaptureMatchee()
        matcher = matchers.Raises(
            matchers.MatchesAll(ReRaiseOtherTypes(),
                                matchers.MatchesException(exc_class, pattern),
                                capture))
        our_callable = testcase.Nullary(callable_obj, *args, **kwargs)
        self.assertThat(our_callable, matcher)
        return capture.matchee