Exemple #1
0
    def test_correct_weights_assigned(self):
        output = frecency.score_items(self.input1, 600)
        for key, value in self.output1.items():
            self.assertAlmostEquals(value, output[key], places=10)
        self.assertEquals(4, len(output))

        output = frecency.score_items(self.input2, 600)
        for key, value in self.output2.items():
            self.assertAlmostEquals(value, output[key], places=10)
        self.assertEquals(2, len(output))

        output = frecency.score_items(self.input3, 600)
        for key, value in self.output3.items():
            self.assertAlmostEquals(value, output[key], places=10)
        self.assertEquals(1, len(output))
Exemple #2
0
 def test_function_parameter(self):
     def test_function(recencies, time_constant):
         return 1
     output1 = {
         'site1': 1,
         'site2': 1,
         'site3': 1,
         'site4': 1,
     }
     output2 = {
         2: 1,
         1: 1,
     }
     output3 = {
         'site2': 1,
     }
     self.assertEquals(output1, frecency.score_items(self.input1,
                 600, test_function))
     self.assertEquals(output2, frecency.score_items(self.input2,
                 600, test_function))
     self.assertEquals(output3, frecency.score_items(self.input3,
                 600, test_function))
Exemple #3
0
 def test_empty_recencies_list_returns_zero(self):
     self.assertEquals({3: 0}, frecency.score_items({3: []}, 600))
     self.assertEquals(0, frecency.score_items({1: [2], 3: []},
                 600)[3])
     self.assertEquals({2: 0}, frecency.score_items({2: []}, 0))
Exemple #4
0
 def test_empty_dict_returns_empty_dict(self):
     self.assertEquals({}, frecency.score_items({}, 600))
     self.assertEquals({}, frecency.score_items({}, 0))
     self.assertEquals({}, frecency.score_items({}, -5))