Exemple #1
0
 def buildKeywordObject(self, token):
     ''' Builds the keyword base objects from the functions'''
     
     kw = keyword(keyword   = str(token),
                  timeStamp = self.ev.timeStamp,
                  lat       = self.ev.lat,
                  lon       = self.ev.lon,
                  text      = self.ev.text,
                  eventID   = self.ev.eventId,
                  userID    = self.ev.userId,
                  source    = self.source,
                  mgrsPrecision=self.mgrsPrecision)
                                 
     self.keywords.append(kw)
Exemple #2
0
 def setUp(self):
     ''' Set up a keyword object to use '''
     
     ts       = datetime.datetime(2011,1,2,12,1,1)
     lat, lon = 34.4, 45.5
     tx1      = 'this text contained the hashtag #keyword1'
     kw1      = 'keyword1'
     tId      = 346664
     uId      = 4444
     source   = 'twitter'
     
     # Build a keyword object for use in testing timeSeries
     self.kw = keyword(keyword=kw1, timeStamp=ts, lat=lat, lon=lon, text=tx1,
                       tweetID=tId, userID=uId, source=source)
     print self.kw.mgrs
Exemple #3
0
 def setUp(self):
     ''' Builds the object in this case '''
     
     # For timing purposes - the start of build
     self.startBuild = datetime.datetime.utcnow()
     
     keyword1='helloWorLD'
     timeStamp=datetime.datetime(year=2011,month=1,day=2,hour=10,minute=30,second=45)
     lat = 45.5
     lon = 34.4  
     text="The strangest thing happened today. Someone said #helloWorLD to ME."
     tweetID=10450066
     userID='brantinr'   # Need to check whether this is a string or number
     source='TWITTER'
     
     # Build a keyword object (keyword 1)
     self.kw = keyword(keyword1, timeStamp, lat, lon, text, tweetID, userID, source)
Exemple #4
0
 def testvastTweet2Json(self):
     ''' Check the conversion to a json object: '''
     
     keyword1='helloWorLD'
     timeStamp=datetime.datetime(year=2011,month=1,day=2,hour=10,minute=30,second=45)
     lat = 45.5
     lon = 34.4  
     text="The strangest thing happened today. Someone said #helloWorLD to ME."
     tweetID=10450066
     userID='brantinr'   # Need to check whether this is a string or number
     source='TWITTER'
     
     # Build a keyword object (keyword 1)
     self.kw = keyword(keyword1, timeStamp, lat, lon, text, tweetID, userID, source)
     
     dumped = json.loads(self.kw.keyword2Json())
     self.assertEqual(dumped['user_id'], 'brantinr')
     self.assertEqual(dumped['keyword'], 'helloworld')
     self.assertEqual(dumped['mgrs'], '36TXR0937739450')