<commit_before># -*- coding: utf-8 -*-

import unittest
from inspector.src.twitter import Twitter
from inspector.src.geocoder import CachedGeocoder


class TestTwitter(unittest.TestCase):

    """ Test twitter class """

    def setUp(self):
        self.twitter = Twitter()

    def test_twitter_constants(self):
        """ Check twitter class has correct values """
        self.assertEquals(self.twitter.query_string, u'{query} since:{since} until:{until} {emotion}')
        self.assertEquals(self.twitter.date_format, '%Y-%m-%d')
        self.assertEquals(self.twitter.geocode, u'44.948056,34.104167,250km')
        self.assertEquals(self.twitter.timeout, 1)

    def test_twitter_search(self):
        """ Test search tweets """
        self.twitter.query_string = u'#test lang:en'
        self.twitter.timeout = 0
        search_list = self.twitter.search(count=10)
        for tweet in search_list['statuses']:
            self.assertIn(u'test', tweet['text'].lower())

    def test_twitter_search_interval(self):
        """ Test search tweets """
        self.twitter.query_string = u'#test lang:en'
        self.twitter.timeout = 0
        search_list = self.twitter.search_interval(query=u'#test lang:en', count=1)
        for tweet in search_list:
            self.assertIn(u'test', tweet['text'].lower())

    def test_tweet2coord(self):
        """ Search tweets and get it coords """
        self.twitter.query_string = u'#test lang:en'
        self.twitter.timeout = 0
        search_list = self.twitter.search(count=10)['statuses']
        geocoder = CachedGeocoder()
        coords = geocoder.tweets_to_coords(search_list)
        for coord in coords:
            self.assertTrue(isinstance(coord[1], tuple))
<commit_msg>test: upd inspector tests<commit_after># -*- coding: utf-8 -*-

import unittest
from inspector.src.twitter import Twitter
from inspector.src.geocoder import CachedGeocoder

from datetime import datetime


class TestTwitter(unittest.TestCase):

    """ Test twitter class """

    def setUp(self):
        self.twitter = Twitter()

    def test_twitter_constants(self):
        """ Check twitter class has correct values """
        self.assertEquals(self.twitter.query_string, u'{query} since:{since} until:{until} {emotion}')
        self.assertEquals(self.twitter.date_format, '%Y-%m-%d')
        self.assertEquals(self.twitter.geocode, u'44.948056,34.104167,250km')
        self.assertEquals(self.twitter.timeout, 1)

    def test_twitter_search(self):
        """ Test search tweets """
        self.twitter.query_string = u'#test lang:en'
        self.twitter.timeout = 0
        search_list = self.twitter.search(count=10)
        for tweet in search_list['statuses']:
            self.assertIn(u'test', tweet['text'].lower())

    def test_twitter_search_interval(self):
        """ Test search tweets """
        self.twitter.query_string = u'#test lang:en'
        self.twitter.timeout = 0
        since = datetime.now().strftime('%Y-%m-%d')
        search_list = self.twitter.search_interval(query=u'#test lang:en', since=since)
        for tweet in search_list:
            self.assertIn(u'test', tweet['text'].lower())

    def test_tweet2coord(self):
        """ Search tweets and get it coords """
        self.twitter.query_string = u'#test lang:en'
        self.twitter.timeout = 0
        search_list = self.twitter.search(count=10)['statuses']
        geocoder = CachedGeocoder()
        coords = geocoder.tweets_to_coords(search_list)
        for coord in coords:
            self.assertTrue(isinstance(coord[1], tuple))

{'fraction_non_alphanumeric': 0.12929349343758725, 'fraction_numerical': 0.017034347947500698, 'mean_word_length': 3.0337837837837838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3606495', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1066, 'n_words': 217}