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))
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))
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))
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))
def testEvaluatesToTrueForClientWithTheLabel(self): r = rdf_foreman.ForemanLabelClientRule(label_names=["world"]) # The client is labeled "world" self.assertTrue(self._Evaluate(r))
def testEvaluatesToFalseForClientWithoutTheLabel(self): r = rdf_foreman.ForemanLabelClientRule(label_names=["arbitrary text"]) # The client isn't labeled "arbitrary text" self.assertFalse(self._Evaluate(r))
def GenerateSample(self, number=0): # Sample rule matches clients labeled str(number) return rdf_foreman.ForemanLabelClientRule(label_names=[str(number)])