示例#1
0
 def generate_fake_hour():
     for version in versions:
         for i in range(random.randint(0, 20)):
             id = uuid.UUID(int=i)
             request = request_factory.get(
                 '/sparkle/%s/%s/appcast.xml?appVersionShort=%s&deviceID=%s'
                 % (app_name, channel, version, id))
             collect_statistics(request, app_id, channel)
 def generate_fake_hour():
     for version in versions:
         for i in range(random.randint(0, 20)):
             id = uuid.UUID(int=i)
             request = request_factory.get('/sparkle/%s/%s/appcast.xml?appVersionShort=%s&deviceID=%s' % (
                 app_name,
                 version.channel,
                 version.short_version,
                 id
             ))
             collect_statistics(request, app_id, version.channel)
示例#3
0
    def test_collect_statistics(self, mock_update_live_statistics):
        app_id = '00000000-0000-0000-0000-000000000001'
        app_name = "Sparrow"
        channel = "test"
        version = "0.0.0.1"
        deviceID = "A37152BF-A3CB-5FEC-8230-FACF43BDCDDD"
        request = RequestFactory().get('/sparkle/%s/%s/appcast.xml?appVersionShort=%s&deviceID=%s' %
                                       (app_name, channel, version, deviceID))

        collect_statistics(request, app_id, channel)

        mock_update_live_statistics.assert_called_with(deviceID, app_id, version)
示例#4
0
    def get(self, request, *args, **kwargs):
        self.appname = self.kwargs.get('app_name')
        self.appid = None
        self.channel = self.kwargs.get('channel')

        try:
            app = Application.objects.get(name=self.kwargs.get('app_name'))
            self.appid = app.id
        except Application.DoesNotExist:
            raise Http404

        collect_statistics(request, self.appid, self.channel)
        return super(SparkleView, self).get(self, request, *args, **kwargs)
示例#5
0
    def get(self, request, *args, **kwargs):
        self.appname = self.kwargs.get('app_name')
        self.appid = None
        self.channel = self.kwargs.get('channel')

        try:
            app = Application.objects.get(name=self.kwargs.get('app_name'))
            self.appid = app.id
        except Application.DoesNotExist:
            raise Http404

        collect_statistics(request, self.appid, self.channel)   # It should be a celery task
        return super(SparkleView, self).get(self, request, *args, **kwargs)