<commit_before>from mock import patch
from socket import socket

from tagalog.shipper.statsd import StatsdShipper

class TestStatsdShipper(object):
    @patch('tagalog.shipper.statsd.socket')
    def test_ship(self, socket_mock):
        ss = StatsdShipper(None,{})
        ss.ship({"@fields.status": 304,"@source_host":"wilmaaaaa"})

        socket_mock.return_value.sendto.assert_called_with('wilmaaaaa.304:1|c',('127.0.0.1',8125))

    @patch('tagalog.shipper.statsd.socket')
    def test_ship_with_provided_metric(self, socket_mock):
        kwargs = {'metric': '%{@source_host}.%{@fields.counter}'}
        ss = StatsdShipper(None, kwargs)
        ss.ship({"@fields.counter": 'test',"@source_host":"wilmaaaaa", "@fields.randomness":"ignored"})

        socket_mock.return_value.sendto.assert_called_with('wilmaaaaa.test:1|c',('127.0.0.1',8125))<commit_msg>Python 3.2 :sob:, fixing encoding<commit_after>from mock import patch
from socket import socket

from tagalog.shipper.statsd import StatsdShipper

class TestStatsdShipper(object):
    @patch('tagalog.shipper.statsd.socket')
    def test_ship(self, socket_mock):
        ss = StatsdShipper(None, {})
        ss.ship({"@fields.status": 304, "@source_host":"wilmaaaaa"})

        socket_mock.return_value.sendto.assert_called_with('wilmaaaaa.304:1|c'.encode('utf-8'), ('127.0.0.1',8125))

    @patch('tagalog.shipper.statsd.socket')
    def test_ship_with_provided_metric(self, socket_mock):
        kwargs = {'metric': '%{@source_host}.%{@fields.counter}'}
        ss = StatsdShipper(None, kwargs)
        ss.ship({"@fields.counter": 'test', "@source_host":"wilmaaaaa", "@fields.randomness":"ignored"})

        socket_mock.return_value.sendto.assert_called_with('wilmaaaaa.test:1|c'.encode('utf-8'), ('127.0.0.1',8125))
{'fraction_non_alphanumeric': 0.16863406408094436, 'fraction_numerical': 0.03372681281618887, 'mean_word_length': 4.836065573770492, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1058209', 'n_tokens_mistral': 670, 'n_tokens_neox': 618, 'n_words': 81}