# Path: geotweet/twitter/stream_steps.py
# class GeoFilterStep(ProcessStep):
#     """
#     Process output from Twitter Streaming API
#     
#     For each record output from the API will be called as argument to process.
#     That function will validate and convert tweet to desired format.
#     
#     """
#     def _validate(self, key, record):
#         if key in record and record[key]:
#             return True
#         return False
# 
#     def validate_geotweet(self, record):
#         """ check that stream record is actual tweet with coordinates """
#         if record and  self._validate('user', record) \
#                 and self._validate('coordinates', record):
#             return True
#         return False
# 
#     def process(self, tweet):
#         """ Passes on tweet if missing 'geo' or 'user' property """
#         if self.validate_geotweet(tweet):
#             return self.next(tweet)
#         return None
# 
# class ExtractStep(ProcessStep):
#     """ Extract interesting fields from Tweet """
#     
#     def process(self, tweet):
#         if not tweet:
#             return None
#         user = tweet['user']
#         data = dict(
#             user_id=user['id'],
#             name=user['name'],
#             screen_name=user['screen_name'],
#             description=user['description'],
#             location=user['location'],
#             friends_count=user['friends_count'],
#             followers_count=user['followers_count'],
#             text=tweet['text'],
#             tweet_id=tweet['id_str'],
#             source=tweet['source'],
#             created_at=tweet['created_at'],
#             timestamp=tweet['timestamp_ms'],
#             lonlat=tweet['coordinates']['coordinates']
#         )
#         return self.next(data)


import unittest
import json
import os
import sys
import inspect
import geotweet
from os.path import dirname
from geotweet.twitter.stream_steps import GeoFilterStep, ExtractStep



root = os.path.dirname(inspect.getfile(geotweet))
TEST_STREAM = os.path.join(root, 'data/twitter-api-stream-raw.log')


class GeoFilterStepTests(unittest.TestCase):

    def setUp(self):

# Path: geotweet/twitter/stream_steps.py
# class GeoFilterStep(ProcessStep):
#     """
#     Process output from Twitter Streaming API
#     
#     For each record output from the API will be called as argument to process.
#     That function will validate and convert tweet to desired format.
#     
#     """
#     def _validate(self, key, record):
#         if key in record and record[key]:
#             return True
#         return False
# 
#     def validate_geotweet(self, record):
#         """ check that stream record is actual tweet with coordinates """
#         if record and  self._validate('user', record) \
#                 and self._validate('coordinates', record):
#             return True
#         return False
# 
#     def process(self, tweet):
#         """ Passes on tweet if missing 'geo' or 'user' property """
#         if self.validate_geotweet(tweet):
#             return self.next(tweet)
#         return None
# 
# class ExtractStep(ProcessStep):
#     """ Extract interesting fields from Tweet """
#     
#     def process(self, tweet):
#         if not tweet:
#             return None
#         user = tweet['user']
#         data = dict(
#             user_id=user['id'],
#             name=user['name'],
#             screen_name=user['screen_name'],
#             description=user['description'],
#             location=user['location'],
#             friends_count=user['friends_count'],
#             followers_count=user['followers_count'],
#             text=tweet['text'],
#             tweet_id=tweet['id_str'],
#             source=tweet['source'],
#             created_at=tweet['created_at'],
#             timestamp=tweet['timestamp_ms'],
#             lonlat=tweet['coordinates']['coordinates']
#         )
#         return self.next(data)


# Path: geotweet/tests/unit/twitter/stream_steps_tests.py
import unittest
import json
import os
import sys
import inspect
import geotweet
from os.path import dirname
from geotweet.twitter.stream_steps import GeoFilterStep, ExtractStep




root = os.path.dirname(inspect.getfile(geotweet))
TEST_STREAM = os.path.join(root, 'data/twitter-api-stream-raw.log')


class GeoFilterStepTests(unittest.TestCase):

    def setUp(self):

        self.step = GeoFilterStep()