def test_shouldComplainAboutDifferentMetrics(): lessStrictQC = QualityConstraint(Context("C1"), CommonMetrics.SECONDS, 15, Comparison.LESS_THAN) moreStrictQC = QualityConstraint(Context("C2"), CommonMetrics.METERS, 10, Comparison.LESS_THAN) lessStrictQC.stricterQC(moreStrictQC)
def test_shouldSelectStricterConstraint(): lessStrictQC = QualityConstraint(Context("C1"), CommonMetrics.SECONDS, 15, Comparison.LESS_THAN) moreStrictQC = QualityConstraint(Context("C2"), CommonMetrics.SECONDS, 10, Comparison.LESS_THAN) assert moreStrictQC is lessStrictQC.stricterQC(moreStrictQC) assert moreStrictQC is moreStrictQC.stricterQC(lessStrictQC)
def test_shouldThereBeMoreThanOneApplicableQCreturnTheStricterOne(): goal = Pragmatic(Decomposition.AND) task = Task() context = Context("C1") anotherContext = Context("C2") fullContext = [] qc = QualityConstraint(context, CommonMetrics.SECONDS, 15, Comparison.LESS_OR_EQUAL_TO) stricter = QualityConstraint(anotherContext, CommonMetrics.SECONDS, 10, Comparison.LESS_OR_EQUAL_TO) goal.addDependency(task) goal.setIdentifier("Root") goal.addApplicableContext(context) goal.interp.addQualityConstraint(qc) goal.interp.addQualityConstraint(stricter) assert stricter == qc.stricterQC(stricter) fullContext.append(context) assert qc in goal.interp.getQualityConstraints(fullContext) fullContext.append(anotherContext) assert stricter in \ goal.interp.getQualityConstraints(fullContext)