Exemple #1
0
    def test_get_trending_regional_negative(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value_with_regions(102, 102,
                                                                  100, 1000)
        _mock.return_value = client

        # 1st week regional count: 99
        # Prior 3 week regional count: 99/3 = 33
        # (99 - 33) / 33 = 2.0 but week1 isn't > 100 so we set to zero.
        eq_(_get_trending(self.app.id)['br'], 0.0)
        # Make sure global trending is still correct.
        eq_(_get_trending(self.app.id)['all'], 2.0)
    def test_get_trending_regional_negative(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value_with_regions(
            102, 102, 100, 1000)
        _mock.return_value = client

        # 1st week regional count: 99
        # Prior 3 week regional count: 99/3 = 33
        # (99 - 33) / 33 = 2.0 but week1 isn't > 100 so we set to zero.
        eq_(_get_trending(self.app.id)['br'], 0.0)
        # Make sure global trending is still correct.
        eq_(_get_trending(self.app.id)['all'], 2.0)
    def test_get_trending_regional(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value_with_regions(
            102, 102, 255, 102)
        _mock.return_value = client

        # We set global counts to anything over 100. See above tests. I chose
        # 102 to divide equally by 3 w/o a crazy remainder.
        #
        # 1st week regional count: 255
        # Prior 3 week regional count: 102/3 = 34
        # (255 - 34) / 34 = 6.5
        eq_(_get_trending(self.app.id)['br'], 6.5)
        # Make sure global trending is still correct.
        eq_(_get_trending(self.app.id)['all'], 2.0)
Exemple #4
0
    def test_get_trending_regional(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value_with_regions(102, 102,
                                                                  255, 102)
        _mock.return_value = client

        # We set global counts to anything over 100. See above tests. I chose
        # 102 to divide equally by 3 w/o a crazy remainder.
        #
        # 1st week regional count: 255
        # Prior 3 week regional count: 102/3 = 34
        # (255 - 34) / 34 = 6.5
        eq_(_get_trending(self.app.id)['br'], 6.5)
        # Make sure global trending is still correct.
        eq_(_get_trending(self.app.id)['all'], 2.0)
    def test_get_trending_threshold(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value(99, 2)
        _mock.return_value = client

        # 1st week count: 99
        # 99 is less than 100 so we return {} as not trending.
        eq_(_get_trending(self.app.id), {})
Exemple #6
0
    def test_get_trending_threshold(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value(99, 2)
        _mock.return_value = client

        # 1st week count: 99
        # 99 is less than 100 so we return {} as not trending.
        eq_(_get_trending(self.app.id), {})
Exemple #7
0
    def test_get_trending_threshold(self, _mock):
        client = mock.Mock()
        client.return_value = [{"count": 49.0, "date": date(2013, 8, 26)}, {"count": 50.0, "date": date(2013, 9, 2)}]
        _mock.return_value = client

        # 1st week count: 49 + 50 = 99
        # 99 is less than 100 so we return 0.0.
        eq_(_get_trending(self.app.id), 0.0)
    def test_get_trending_negative(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value(100, 1000)
        _mock.return_value = client

        # 1st week count: 100
        # Prior 3 week count: 1000/3 = 333.3
        # (100 - 333.3) / 333.3 = -0.7 which gets set to 0.0.
        eq_(_get_trending(self.app.id), {'all': 0.0})
    def test_get_trending(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value(255, 255)
        _mock.return_value = client

        # 1st week count: 255
        # Prior 3 weeks get averaged: (255) / 3 = 85
        # (255 - 85) / 85 = 2.0
        eq_(_get_trending(self.app.id), {'all': 2.0})
Exemple #10
0
    def test_get_trending_negative(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value(100, 1000)
        _mock.return_value = client

        # 1st week count: 100
        # Prior 3 week count: 1000/3 = 333.3
        # (100 - 333.3) / 333.3 = -0.7 which gets set to 0.0.
        eq_(_get_trending(self.app.id), {'all': 0.0})
Exemple #11
0
    def test_get_trending(self, _mock):
        client = mock.Mock()
        client.raw.return_value = self._return_value(255, 255)
        _mock.return_value = client

        # 1st week count: 255
        # Prior 3 weeks get averaged: (255) / 3 = 85
        # (255 - 85) / 85 = 2.0
        eq_(_get_trending(self.app.id), {'all': 2.0})
Exemple #12
0
    def test_get_trending(self, _mock):
        client = mock.Mock()
        client.return_value = [{"count": 133.0, "date": date(2013, 8, 26)}, {"count": 122.0, "date": date(2013, 9, 2)}]
        _mock.return_value = client

        # 1st week count: 133 + 122 = 255
        # Prior 3 weeks get averaged: (133 + 122) / 3 = 85
        # (255 - 85) / 85 = 2.0
        eq_(_get_trending(self.app.id), 2.0)
Exemple #13
0
    def test_get_trending_threshold(self, _mock):
        client = mock.Mock()
        client.return_value = [
            {
                'count': 49.0,
                'date': date(2013, 8, 26)
            },
            {
                'count': 50.0,
                'date': date(2013, 9, 2)
            },
        ]
        _mock.return_value = client

        # 1st week count: 49 + 50 = 99
        # 99 is less than 100 so we return 0.0.
        eq_(_get_trending(self.app.id), 0.0)
Exemple #14
0
    def test_get_trending(self, _mock):
        client = mock.Mock()
        client.return_value = [
            {
                'count': 133.0,
                'date': date(2013, 8, 26)
            },
            {
                'count': 122.0,
                'date': date(2013, 9, 2)
            },
        ]
        _mock.return_value = client

        # 1st week count: 133 + 122 = 255
        # Prior 3 weeks get averaged: (133 + 122) / 3 = 85
        # (255 - 85) / 85 = 2.0
        eq_(_get_trending(self.app.id), 2.0)
Exemple #15
0
    def test_get_trending_error(self, _mock):
        client = mock.Mock()
        client.raw.side_effect = ValueError
        _mock.return_value = client

        eq_(_get_trending(self.app.id), {})
Exemple #16
0
    def test_get_trending_error(self, _mock):
        client = mock.Mock()
        client.raw.side_effect = ValueError
        _mock.return_value = client

        eq_(_get_trending(self.app.id), {})