예제 #1
0
파일: content.py 프로젝트: oskgeek/liftpass
    def testExport(self):
        # Create game
        backend = content.Content()
        theAnalytics = analytics.Analytics()
        session = content.models.getSession()

        a = backend.addApplication('Export Data Game')

        for i in range(10):
            update = {
                'liftpass-application':
                a.key,
                'liftpass-ip':
                '',
                'user':
                '******' * 32,
                'events': [{
                    'name': 'liftpass-metric',
                    'progress': [None] * 32,
                    'time': extras.unixTimestamp()
                }] * 5
            }
            theAnalytics.processUpdate(update, session)

        query = {
            'application': a.key,
            'from': extras.unixTimestamp() - 86400,
            'to': extras.unixTimestamp() + 86400,
        }

        (status, a) = self.request('GET', '/export/json/v1/', query, raw=True)

        self.assertEqual(len(a.split('\n')), 51)
예제 #2
0
	def testExport(self):
		# Create game
		backend = content.Content()
		theAnalytics = analytics.Analytics()
		session = content.models.getSession()

		a = backend.addApplication('Export Data Game') 
	
		for i in range(10):
			update = {
				'liftpass-application': a.key,
				'liftpass-ip': '',
				'user': '******'*32,
				'events':[
					{
						'name': 'liftpass-metric',
						'progress': [None]*32,
						'time': extras.unixTimestamp()
					}
				]*5
			}
			theAnalytics.processUpdate(update, session)
			
		query = {
			'application': a.key,
			'from': extras.unixTimestamp()-86400,
			'to': extras.unixTimestamp()+86400,
		}

		(status, a) = self.request('GET', '/export/json/v1/', query, raw=True)
		
		
		self.assertEqual(len(a.split('\n')), 51)
예제 #3
0
	def testMissingEventMetrics(self):
		update = {
			'name': 'liftpass-metric',
			'progress': [None]*23,
			'time': extras.unixTimestamp(),
		}
		with self.assertRaises(analytics.EventMissingMetricError):
			event = analytics.Analytics().processEvent(None, None, None, None, update)

		update = {
			'name': 'liftpass-metric',
			'time': extras.unixTimestamp(),
		}
		with self.assertRaises(analytics.EventAttributeMissingError):
			event = analytics.Analytics().processEvent(None, None, None, None, update)
예제 #4
0
	def testLog(self):

		backend = content.Content()
		a = backend.addApplication('Test SDK')
		
		jsonPricesA = backend.addPrices(a.key, 'JSON', json.dumps({'sword':1000}), None)
		jsonPricesB = backend.addPrices(a.key, 'JSON', json.dumps({'sword':2000}), None)
		
		backend.setABTest(a.key, {'groupAPrices_key': jsonPricesA.key})
		backend.setABTest(a.key, {'groupBPrices_key': jsonPricesB.key})
		
		data = {
			'user': '******'*32,
			'liftpass-debug': True,
			'events': [
				{
					'name': 'liftpass-metric',
					'progress': ['','','','','','','','']+[0]*32,
					'time': extras.unixTimestamp()
				}
			]
		}

		(status, b) = self.request('POST', '/sdk/update/v1/', data, application=a)

		theTerminal = terminal.getTerminal()

		res = theTerminal.get(a.key)

		self.assertEqual(len(res), 2)
예제 #5
0
    def testLog(self):

        backend = content.Content()
        a = backend.addApplication('Test SDK')

        jsonPricesA = backend.addPrices(a.key, 'JSON',
                                        json.dumps({'sword': 1000}), None)
        jsonPricesB = backend.addPrices(a.key, 'JSON',
                                        json.dumps({'sword': 2000}), None)

        backend.setABTest(a.key, {'groupAPrices_key': jsonPricesA.key})
        backend.setABTest(a.key, {'groupBPrices_key': jsonPricesB.key})

        data = {
            'user':
            '******' * 32,
            'liftpass-debug':
            True,
            'events': [{
                'name': 'liftpass-metric',
                'progress': ['', '', '', '', '', '', '', ''] + [0] * 32,
                'time': extras.unixTimestamp()
            }]
        }

        (status, b) = self.request('POST',
                                   '/sdk/update/v1/',
                                   data,
                                   application=a)

        theTerminal = terminal.getTerminal()

        res = theTerminal.get(a.key)

        self.assertEqual(len(res), 3)
예제 #6
0
	def testCall(self):

		backend = content.Content()
		a = backend.addApplication('Test SDK')
		
		jsonPricesA = backend.addPrices(a.key, 'JSON', json.dumps({'sword':1000}), None)
		jsonPricesB = backend.addPrices(a.key, 'JSON', json.dumps({'sword':2000}), None)

		backend.setABTest(a.key, {'groupAPrices_key': jsonPricesA.key})
		backend.setABTest(a.key, {'groupBPrices_key': jsonPricesB.key})
		
		data = {
			'user': '******'*32,
			'events': [
				{
					'name': 'liftpass-metric',
					'progress': ['','','','','','','','']+[0]*24,
					'time': extras.unixTimestamp()
				}
			]
		}

		(status, b) = self.request('POST', '/sdk/update/v1/', data, application=a)
		self.assertEqual(b['goods']['sword'][0], 1000)

		data['user'] = '******'*32
		(status, c) = self.request('POST', '/sdk/update/v1/', data, application=a)
		self.assertEqual(c['goods']['sword'][0], 2000)
예제 #7
0
파일: content.py 프로젝트: oskgeek/liftpass
    def testCall(self):

        backend = content.Content()
        a = backend.addApplication('Test SDK')

        jsonPricesA = backend.addPrices(a.key, 'JSON',
                                        json.dumps({'sword': 1000}), None)
        jsonPricesB = backend.addPrices(a.key, 'JSON',
                                        json.dumps({'sword': 2000}), None)

        backend.setABTest(a.key, {'groupAPrices_key': jsonPricesA.key})
        backend.setABTest(a.key, {'groupBPrices_key': jsonPricesB.key})

        data = {
            'user':
            '******' * 32,
            'events': [{
                'name': 'liftpass-metric',
                'progress': ['', '', '', '', '', '', '', ''] + [0] * 24,
                'time': extras.unixTimestamp()
            }]
        }

        (status, b) = self.request('POST',
                                   '/sdk/update/v1/',
                                   data,
                                   application=a)
        self.assertEqual(b['goods']['sword'][0], 1000)

        data['user'] = '******' * 32
        (status, c) = self.request('POST',
                                   '/sdk/update/v1/',
                                   data,
                                   application=a)
        self.assertEqual(c['goods']['sword'][0], 2000)
예제 #8
0
    def testNormalUpdate(self):
        update = {
            'name': 'liftpass-metric',
            'progress': [],
            'time': extras.unixTimestamp(),
        }

        for i in range(8):
            update['progress'].append(extras.genRandomStrings(1, 12)[0])
        for i in range(24):
            update['progress'].append(random.random())

        event = analytics.Analytics().processEvent(None, None, None, None,
                                                   update)

        self.assertEqual(event['name'], update['name'])
        self.assertEqual(event['timestamp'],
                         datetime.datetime.utcfromtimestamp(update['time']))

        for i in range(8):
            self.assertEqual(event['metricString%d' % (i + 1)],
                             update['progress'][i])
        for i in range(24):
            self.assertEqual(event['metricNumber%d' % (i + 1)],
                             update['progress'][8 + i])
예제 #9
0
 def testMissingEventName(self):
     update = {
         'progress': [None] * 23,
         'time': extras.unixTimestamp(),
     }
     with self.assertRaises(analytics.EventAttributeMissingError):
         event = analytics.Analytics().processEvent(None, None, None, None,
                                                    update)
예제 #10
0
 def testMissingAttribute(self):
     update = {
         'name': 'liftpass-metric',
         'progress': [None] * 32,
         'attributes': [None] * 12,
         'time': extras.unixTimestamp(),
     }
     with self.assertRaises(analytics.EventMissingAttributeError):
         event = analytics.Analytics().processEvent(None, None, None, None,
                                                    update)
예제 #11
0
	def testNullMetrics(self):
		update = {
			'name': 'liftpass-metric',
			'progress': [None]*32,
			'time': extras.unixTimestamp(),
		}
		event = analytics.Analytics().processEvent(None, None, None, None, update)
		for i in range(8):
			self.assertEqual(event['metricString%d'%(i+1)], update['progress'][i])
		for i in range(24):
			self.assertEqual(event['metricNumber%d'%(i+1)], update['progress'][8+i])
예제 #12
0
파일: stress.py 프로젝트: oskgeek/liftpass
def makeProgress(length):

	progress = ['','','','','','','','']+[0]*24
	res = []
	for i in range(length):
		progress[random.randint(8, 31)] += 1
		
		res.append({
				'name': 'liftpass-metric',
				'progress': progress[:],
				'time': extras.unixTimestamp()+i
		})
	return res
예제 #13
0
 def testNullMetrics(self):
     update = {
         'name': 'liftpass-metric',
         'progress': [None] * 32,
         'time': extras.unixTimestamp(),
     }
     event = analytics.Analytics().processEvent(None, None, None, None,
                                                update)
     for i in range(8):
         self.assertEqual(event['metricString%d' % (i + 1)],
                          update['progress'][i])
     for i in range(24):
         self.assertEqual(event['metricNumber%d' % (i + 1)],
                          update['progress'][8 + i])
예제 #14
0
def makeRequest(*args, **kwargs):
	global api, application

	data = {
		'user': '******'*32,
		'events': [
			{
				'name': 'liftpass-metric',
				'progress': ['','','','','','','','']+[0]*24,
				'time': extras.unixTimestamp()
			}
		]
	}

	start = time.time()
	(status, b) = api.request('POST', '/sdk/update/v1/', data, application=application)
	data['user'] = '******'*32
	(status, c) = api.request('POST', '/sdk/update/v1/', data, application=application)
	
	return time.time() - start
예제 #15
0
	def testNormalUpdate(self):
		update = {
			'name': 'liftpass-metric',
			'progress': [],
			'time': extras.unixTimestamp(),
		}

		for i in range(8):
			update['progress'].append(extras.genRandomStrings(1, 12)[0])
		for i in range(24):
			update['progress'].append(random.random())

		event = analytics.Analytics().processEvent(None, None, None, None, update)

		self.assertEqual(event['name'], update['name'])
		self.assertEqual(event['timestamp'], datetime.datetime.utcfromtimestamp(update['time']))
		
		for i in range(8):
			self.assertEqual(event['metricString%d'%(i+1)], update['progress'][i])
		for i in range(24):
			self.assertEqual(event['metricNumber%d'%(i+1)], update['progress'][8+i])