Ejemplo n.º 1
0
    def testEvaluatesToTrueInMatchAllModeIfClientHasAllOfTheLabels(self):
        r = rdf_foreman.ForemanLabelClientRule(
            match_mode=rdf_foreman.ForemanLabelClientRule.MatchMode.MATCH_ALL,
            label_names=["world", "hello"])

        # The client is labeled both "world" and "hello"
        self.assertTrue(self._Evaluate(r))
Ejemplo n.º 2
0
    def testEvaluatesToFalseInMatchAnyModeIfClientHasNoneOfTheLabels(self):
        r = rdf_foreman.ForemanLabelClientRule(
            match_mode=rdf_foreman.ForemanLabelClientRule.MatchMode.MATCH_ANY,
            label_names=["nonexistent", "arbitrary"])

        # The client isn't labeled "nonexistent", nor "arbitrary"
        self.assertFalse(self._Evaluate(r))
Ejemplo n.º 3
0
    def testEvaluatesToTrueInMatchAnyModeIfClientHasOneOfTheLabels(self):
        r = rdf_foreman.ForemanLabelClientRule(
            match_mode=rdf_foreman.ForemanLabelClientRule.MatchMode.MATCH_ANY,
            label_names=["nonexistent", "world"])

        # The client is labeled "world"
        self.assertTrue(self._Evaluate(r))
Ejemplo n.º 4
0
    def testEvaluatesToFalseInMatchAllModeIfClientDoesntHaveOneOfTheLabels(
            self):
        r = rdf_foreman.ForemanLabelClientRule(
            match_mode=rdf_foreman.ForemanLabelClientRule.MatchMode.MATCH_ALL,
            label_names=["world", "random"])

        # The client isn't labeled "random"
        self.assertFalse(self._Evaluate(r))
Ejemplo n.º 5
0
    def testEvaluatesToTrueForClientWithTheLabel(self):
        r = rdf_foreman.ForemanLabelClientRule(label_names=["world"])

        # The client is labeled "world"
        self.assertTrue(self._Evaluate(r))
Ejemplo n.º 6
0
    def testEvaluatesToFalseForClientWithoutTheLabel(self):
        r = rdf_foreman.ForemanLabelClientRule(label_names=["arbitrary text"])

        # The client isn't labeled "arbitrary text"
        self.assertFalse(self._Evaluate(r))
Ejemplo n.º 7
0
 def GenerateSample(self, number=0):
     # Sample rule matches clients labeled str(number)
     return rdf_foreman.ForemanLabelClientRule(label_names=[str(number)])