Esempio n. 1
0
    def test_valid_configuration(self):
        s = Schwa(".")
        configs = {
            "commits": 100,
            "features_weights": {
                "revisions": 0.2,
                "fixes": 0.3,
                "authors": 0.5
            }
        }
        max_commits = None
        max_commits = s.configure_yaml(configs, max_commits)
        self.assertEqual(max_commits, 100)
        self.assertEqual(Metrics.REVISIONS_WEIGHT, 0.2)
        self.assertEqual(Metrics.FIXES_WEIGHT, 0.3)
        self.assertEqual(Metrics.AUTHORS_WEIGHT, 0.5)

        max_commits = 2
        max_commits = s.configure_yaml(configs, max_commits)
        self.assertEqual(max_commits, 2)

        del configs["features_weights"]
        self.reset_weights()
        s.configure_yaml(configs, max_commits)
        self.assertEqual(Metrics.REVISIONS_WEIGHT, self.r_w)
        self.assertEqual(Metrics.FIXES_WEIGHT, self.f_w)
        self.assertEqual(Metrics.AUTHORS_WEIGHT, self.a_w)
Esempio n. 2
0
    def test_wrong_weights(self):
        s = Schwa(".")
        configs = {
            "commits": 100,
            "features_weights": {
                "revisions": 0.4,
                "fixes": 0.3,
                "authors": 0.5
            }
        }
        self.reset_weights()
        max_commits = None

        with self.assertRaises(SchwaConfigurationException):
            max_commits = s.configure_yaml(configs, max_commits)