Beispiel #1
0
    def testRankSubdimensionsRatio(self):
        t = str(time.time())
        pk = 'test_ratio_rank'
        # OVERALL STATS: 529,994 value, 50,000 visitors, 10.6 value per visitor
        # Not important, too close to overall
        self.whale.count_now(pk, [t, 'a', 'asub1'],
            {'value': 54989, 'visitors': 4999})  # 11 value per visitor
        # Important, high relative ratio
        self.whale.count_now(pk, [t, 'a', 'asub2'],
            {'value': 375000, 'visitors': 25000})  # 15 value per visitor
        # Important, low relative ratio
        self.whale.count_now(pk, [t, 'b'],
            {'value': 100000, 'visitors': 20000})  # 5 value per visitor
        # Not important, not enough visitors
        self.whale.count_now(pk, [t, 'c'],
            {'value': 5, 'visitors': 1})  # 5 value per visitor

        one_level = self.whale.rank_subdimensions_ratio('test_rank_ratio', 'value', 'visitors',
            t, recursive=False)

        all_levels = self.whale.rank_subdimensions_ratio(pk, 'value', 'visitors', t)
        self.assertEqual(True, maybe_dumps([t, 'a', 'asub1']) not in one_level)
        self.assertEqual(all_levels[maybe_dumps([t, 'a', 'asub1'])]['important'], False)
        self.assertEqual(all_levels[maybe_dumps([t, 'a', 'asub2'])]['important'], True)
        self.assertEqual(all_levels[maybe_dumps([t, 'b'])]['important'], True)
        self.assertEqual(all_levels[maybe_dumps([t, 'c'])]['important'], False)
Beispiel #2
0
    def testRankSubdimensionsRatio(self):
        t = str(time.time())
        pk = 'test_ratio_rank'
        # OVERALL STATS: 529,994 value, 50,000 visitors, 10.6 value per visitor
        # Not important, too close to overall
        self.whale.count_now(pk, [t, 'a', 'asub1'],
            {'value': 54989, 'visitors': 4999})  # 11 value per visitor
        # Important, high relative ratio
        self.whale.count_now(pk, [t, 'a', 'asub2'],
            {'value': 375000, 'visitors': 25000})  # 15 value per visitor
        # Important, low relative ratio
        self.whale.count_now(pk, [t, 'b'],
            {'value': 100000, 'visitors': 20000})  # 5 value per visitor
        # Not important, not enough visitors
        self.whale.count_now(pk, [t, 'c'],
            {'value': 5, 'visitors': 1})  # 5 value per visitor

        one_level = self.whale.rank_subdimensions_ratio('test_rank_ratio', 'value', 'visitors',
            t, recursive=False)

        all_levels = self.whale.rank_subdimensions_ratio(pk, 'value', 'visitors', t)
        self.assertEqual(True, maybe_dumps([t, 'a', 'asub1']) not in one_level)
        self.assertEqual(all_levels[maybe_dumps([t, 'a', 'asub1'])]['important'], False)
        self.assertEqual(all_levels[maybe_dumps([t, 'a', 'asub2'])]['important'], True)
        self.assertEqual(all_levels[maybe_dumps([t, 'b'])]['important'], True)
        self.assertEqual(all_levels[maybe_dumps([t, 'c'])]['important'], False)
Beispiel #3
0
 def testRankSubdimensionsScalar(self):
     t = str(time.time())
     self.whale.count_now('test_rank', [t, 'a', 'asub1'], {'value': 1})
     self.whale.count_now('test_rank', [t, 'a', 'asub2'], {'value': 30})
     self.whale.count_now('test_rank', [t, 'b'], {'value': 80})
     self.whale.count_now('test_rank', [t, 'c'], {'value': 10})
     ranked = self.whale.rank_subdimensions_scalar('test_rank', t, 'value')
     self.assertEqual(ranked[maybe_dumps([t, 'a'])]['important'], False)
     self.assertEqual(ranked[maybe_dumps([t, 'a', 'asub1'])]['important'], False)
     self.assertEqual(ranked[maybe_dumps([t, 'a', 'asub2'])]['important'], True)
     self.assertEqual(ranked[maybe_dumps([t, 'b'])]['important'], True)
     self.assertEqual(ranked[maybe_dumps([t, 'c'])]['important'], False)
Beispiel #4
0
    def testRankSubdimensionsScalar(self):
        t = str(time.time())
        self.whale.count_now('test_rank', [t, 'a', 'asub1'], {'value': 1})
        self.whale.count_now('test_rank', [t, 'a', 'asub2'], {'value': 30})
        self.whale.count_now('test_rank', [t, 'b'], {'value': 80})
        self.whale.count_now('test_rank', [t, 'c'], {'value': 10})
        ranked = self.whale.rank_subdimensions_scalar('test_rank', t, 'value')

        self.assertEqual(ranked[maybe_dumps([t, 'a'])]['important'], False)
        self.assertEqual(ranked[maybe_dumps([t, 'a', 'asub1'])]['important'], False)
        self.assertEqual(ranked[maybe_dumps([t, 'a', 'asub2'])]['important'], True)
        self.assertEqual(ranked[maybe_dumps([t, 'b'])]['important'], True)
        self.assertEqual(ranked[maybe_dumps([t, 'c'])]['important'], False)
Beispiel #5
0
    def testPlotpointsDepth(self):
        t = str(time.time())
        self.whale.count_now('test_depth', {t: 'a'})
        self.whale.count_now('test_depth', {t: 'b'})
        self.whale.count_now('test_depth', {t: 'b'})
        self.whale.count_now('test_depth', {t: {'c': 'child'}})
        # Test 1 level deep
        plotpoints = self.whale.plotpoints('test_depth', t, points_type=list, depth=1)
        
        self.assertEqual(plotpoints[maybe_dumps([t, 'a'])]['hits'][-1][1], 1)
        self.assertEqual(plotpoints[maybe_dumps([t, 'b'])]['hits'][-1][1], 2)
        self.assertEqual(plotpoints[maybe_dumps([t, 'c'])]['hits'][-1][1], 1)
        self.assertEqual(False, maybe_dumps([t, 'c', 'child']) in plotpoints)
        # Test 2 levels deep
        plotpoints = self.whale.plotpoints('test_depth', t, points_type=list, depth=2)
        
        self.assertEqual(True, maybe_dumps([t, 'c', 'child']) in plotpoints)
        self.assertEqual(plotpoints[maybe_dumps([t, 'c', 'child'])]['hits'][-1][1], 1)


        # Test ranking and limiting i.e assign rank on the basis of value and then extract top limit candidate
        plotpoints = self.whale.plotpoints('test_depth', t, points_type=list,depth=1, limit=2)
        
        #self.assertEqual(plotpoints[maybe_dumps([t, 'b'])]['hits'][-1][1], 2)
        self.assertEqual(True, maybe_dumps([t, 'a']) not in plotpoints)
        self.assertEqual(True, maybe_dumps([t, 'c']) not in plotpoints)
Beispiel #6
0
    def testPlotpointsDepth(self):
        t = str(time.time())
        self.whale.count_now('test_depth', {t: 'a'})
        self.whale.count_now('test_depth', {t: 'b'})
        self.whale.count_now('test_depth', {t: 'b'})
        self.whale.count_now('test_depth', {t: {'c': 'child'}})
        # Test 1 level deep
        plotpoints = self.whale.plotpoints('test_depth', t, points_type=list, depth=1)
        self.assertEqual(plotpoints[maybe_dumps([t, 'a'])]['hits'][-1][1], 1)
        self.assertEqual(plotpoints[maybe_dumps([t, 'b'])]['hits'][-1][1], 2)
        self.assertEqual(plotpoints[maybe_dumps([t, 'c'])]['hits'][-1][1], 1)
        self.assertEqual(False, maybe_dumps([t, 'c', 'child']) in plotpoints)
        # Test 2 levels deep
        plotpoints = self.whale.plotpoints('test_depth', t, points_type=list, depth=2)
        self.assertEqual(True, maybe_dumps([t, 'c', 'child']) in plotpoints)
        self.assertEqual(plotpoints[maybe_dumps([t, 'c', 'child'])]['hits'][-1][1], 1)

        # Test ranking and limiting
        plotpoints = self.whale.plotpoints('test_depth', t, points_type=list,
                depth=1, limit=2)
        self.assertEqual(plotpoints[maybe_dumps([t, 'b'])]['hits'][-1][1], 2)
        self.assertNotIn(maybe_dumps([t, 'a']), plotpoints)
        self.assertNotIn(maybe_dumps([t, 'c']), plotpoints)