def test_nomerges_condition (self): """Test SCM object with a no merges condition""" nomerges = NomergesCondition () data = SCM (database = database, var = "ncommits", conditions = (nomerges,)) self.assertEqual (data.total(), 4206)
def test_branches_condition (self): """Test SCM object with a branches condition""" # Master branch branches = BranchesCondition (branches = ("master",)) data = SCM (database = database, var = "ncommits", conditions = (branches,)) self.assertEqual (data.total(), 3685)
def value (self): """Obtain the value for a variable""" if self.param["family"] == "scm": data = SCM (database = self.database, var = self.param["id"], conditions = self.conditions) if self.param["type"] == "total": return data.total() elif self.param["type"] == "timeseries": return data.timeseries() else: raise Exception ("Unknown family: " + self.param["family"] \ + " (variable: " + variable + ")")
def test_combined_conditions (self): """Test SCM object with a combination of conditions""" # Branches and period, and the other way around branches = BranchesCondition (branches = ("master",)) period = PeriodCondition (start = self.start, end = self.end, date = "author") data = SCM (database = database, var = "ncommits", conditions = (branches,period)) self.assertEqual (data.total(), 647) data = SCM (database = database, var = "ncommits", conditions = (period, branches)) self.assertEqual (data.total(), 647) # Branches, period and merges (in several orders) nomerges = NomergesCondition () data = SCM (database = database, var = "ncommits", conditions = (nomerges, period, branches)) self.assertEqual (data.total(), 647) data = SCM (database = database, var = "ncommits", conditions = (branches, nomerges, period)) self.assertEqual (data.total(), 647)
def test_period_condition (self): """Test SCM object with a period condition""" # Only start for period period = PeriodCondition (start = self.start, end = None) data = SCM (database = database, var = "ncommits", conditions = (period,)) self.assertEqual (data.total(), 839) # Start and end period = PeriodCondition (start = self.start, end = self.end) data = SCM (database = database, var = "ncommits", conditions = (period,)) self.assertEqual (data.total(), 730) # Start and end, authoring date period = PeriodCondition (start = self.start, end = self.end, date = "author") data = SCM (database = database, var = "ncommits", conditions = (period,)) self.assertEqual (data.total(), 728)
def test_no_condition (self): """Test SCM object with no conditions""" data = SCM (database = database, var = "ncommits") self.assertEqual (data.total(), 4465)