def test_get_motw_expiration(self): map_data = self.get_map_data() # Get after a map with a very short expiration time, so it uses the default. self.assertEqual('de_dust2', motw.get_motw(map_data, 1441497600 + 100, 'esea', 100, 'default')) self.assertEqual('default', motw.get_motw(map_data, 1441497600 + 100, 'esea', 99, 'default')) self.assertEqual('de_mirage', motw.get_motw(map_data, 1444521600 + 100, 'cevo', 100, 'default')) self.assertEqual('default', motw.get_motw(map_data, 1444521600 + 100, 'cevo', 99, 'default'))
def get(self): # Get URL params. league = self.request.get("league", motw.DEFAULT_LEAGUE) default_map = self.request.get("default", motw.DEFAULT_MAP) try: timestamp = int(self.request.get("timestamp", time.time())) except ValueError: self.error(400) self.response.write('Illegal value for parameter "timestamp"') return try: expiration = int(self.request.get("expiration", motw.DEFAULT_EXPIRATION)) except ValueError: self.error(400) self.response.write('Illegal value for parameter "expiration"') return try: time_offset = int(self.request.get("offset", 0)) except ValueError: self.error(400) self.response.write('Illegal value for parameter "offset"') return if league in map_data: result_map = motw.get_motw(map_data, timestamp + time_offset, league, expiration, default_map) self.response.write(result_map) else: self.error(400) self.response.write('Illegal value for parameter "league"')
def test_get_motw(self): map_data = self.get_map_data() # Check before any map record time exists. self.assertEqual('default', motw.get_motw(map_data, 1, 'esea', 1000000, 'default')) # Check normal time intervals near the start dates for each map. self.assertEqual('de_dust2', motw.get_motw(map_data, 1441497600, 'esea', 1000000, 'default')) self.assertEqual('de_dust2', motw.get_motw(map_data, 1442102400 - 1, 'esea', 1000000, 'default')) self.assertEqual('de_train', motw.get_motw(map_data, 1442102400, 'esea', 1000000, 'default')) self.assertEqual('de_train', motw.get_motw(map_data, 1442102400 + 1, 'esea', 1000000, 'default')) self.assertEqual('de_train', motw.get_motw(map_data, 1442707200 - 1, 'esea', 1000000, 'default')) self.assertEqual('de_mirage', motw.get_motw(map_data, 1442707200, 'esea', 1000000, 'default')) self.assertEqual('de_cbble', motw.get_motw(map_data, 1443312000, 'esea', 1000000, 'default')) self.assertEqual('de_overpass', motw.get_motw(map_data, 1443916800, 'esea', 1000000, 'default')) self.assertEqual('de_mirage', motw.get_motw(map_data, 1444521600, 'esea', 1000000, 'default')) self.assertEqual('de_inferno', motw.get_motw(map_data, 1445126400, 'esea', 1000000, 'default')) self.assertEqual('de_cache', motw.get_motw(map_data, 1445731200, 'esea', 1000000, 'default')) self.assertEqual('de_dust2', motw.get_motw(map_data, 1446336000, 'esea', 1000000, 'default'))