<commit_before>"""Test TAF Parsing"""
import os
import unittest

from pyiem.nws.products.taf import parser as nhcparser


def get_file(name):
    ''' Helper function to get the text file contents '''
    basedir = os.path.dirname(__file__)
    fn = "%s/../../../../data/product_examples/TAF/%s" % (basedir, name)
    return open(fn).read()


class TestProducts(unittest.TestCase):
    """ Tests """

    def test_parse(self):
        """TAF type"""
        prod = nhcparser(get_file("TAFJFK.txt"))
        j = prod.get_jabbers("http://localhost", "http://localhost")
        self.assertEquals(j[0][0],
                          ("OKX issues Terminal Aerodrome Forecast (TAF) "
                           "for JFK http://localhost?"
                           "pid=201707251341-KOKX-FTUS41-TAFJFK"))
        assert "TAFJFK" in j[0][2]['channels'].split(",")<commit_msg>correct non-deterministic TAF test found by Travis-CI<commit_after>"""Test TAF Parsing"""
import os
import unittest
import datetime

import pytz
from pyiem.nws.products.taf import parser as tafparser


def get_file(name):
    ''' Helper function to get the text file contents '''
    basedir = os.path.dirname(__file__)
    fn = "%s/../../../../data/product_examples/TAF/%s" % (basedir, name)
    return open(fn).read()


class TestProducts(unittest.TestCase):
    """ Tests """

    def test_parse(self):
        """TAF type"""
        utcnow = datetime.datetime(2017, 7, 25).replace(tzinfo=pytz.utc)
        prod = tafparser(get_file("TAFJFK.txt"), utcnow=utcnow)
        j = prod.get_jabbers("http://localhost", "http://localhost")
        self.assertEquals(j[0][0],
                          ("OKX issues Terminal Aerodrome Forecast (TAF) "
                           "for JFK http://localhost?"
                           "pid=201707251341-KOKX-FTUS41-TAFJFK"))
        assert "TAFJFK" in j[0][2]['channels'].split(",")
{'fraction_non_alphanumeric': 0.1559196617336152, 'fraction_numerical': 0.022727272727272728, 'mean_word_length': 2.531716417910448, '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': '1349534', 'n_tokens_mistral': 645, 'n_tokens_neox': 598, 'n_words': 130}