#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
test_events
----------------------------------

Tests for `events` module.
"""
import os
import unittest

from coast_core import events


class TestEvents(unittest.TestCase):

    def setUp(self):
        self.link = "https://www.joelonsoftware.com/2006/09/01/language-wars/"
        self.file = open(os.path.dirname(__file__) + "/test_data/language_wars.html")
        self.html = self.file.read()
        import nltk
        nltk.download('punkt')

    def test_run_all_event(self):
        result = events.run_all_event_analysis(self.html)
        expected_result = {'iverb_bigrams': {'events': [{'bigram': ('I', 'wanted'),
                                                         'verb': ('wanted', 'VBD')},
                                                        {'bigram': ('I', 'wrote'),
                                                         'verb': ('wrote', 'VBD')},
                                                        {'bigram': ('I', 'mentioned'),
                                                         'verb': ('mentioned', 'VBN')}],
                                             'total': 3},
                           'timex_events': ['when', 'when', 'when', 'since', 'when'],
                           'verb_events': [('Grab', 'VB'),
                                           ('<', 'VBD'),
                                           ('span', 'VBD'),
                                           ('span', 'VBD'),
                                           ('<', 'VBD'),
                                           ('<', 'VBD'),
                                           ('emailed', 'VBD'),
                                           ('ask', 'VB'),
                                           ('wanted', 'VBD'),
                                           ('get', 'VB'),
                                           ('concerning', 'VBG'),
                                           ('creating', 'VBG'),
                                           ('starting', 'VBG'),
                                           ('won', 'VBD'),
                                           ('/p', 'VB'),
                                           ('use', 'VB'),
                                           ('recommend', 'VB'),
                                           ('use', 'VB'),
                                           ('/p', 'VB'),
                                           ('answer', 'VB'),
                                           ('answer', 'VB'),
                                           ('stop', 'VB'),
                                           ('wrote', 'VBD'),
                                           ('claimed', 'VBD'),
                                           ('programming', 'VBG'),
                                           ('were', 'VBD'),
                                           ('complicated', 'VBD'),
                                           ('tell', 'VB'),
                                           ('were', 'VBD'),
                                           ('going', 'VBG'),
                                           ('be', 'VB'),
                                           ('was', 'VBD'),
                                           ('go', 'VB'),
                                           ('debate', 'VB'),
                                           ('debate', 'VB'),
                                           ('get', 'VB'),
                                           ('think', 'VB'),
                                           ('find', 'VB'),
                                           ('be', 'VB'),
                                           ('ask', 'VB'),
                                           ('found', 'VBD'),
                                           ('know', 'VB'),
                                           ('building', 'VBG'),
                                           ('using', 'VBG'),
                                           ('using', 'VBG'),
                                           ('using', 'VBG'),
                                           ('failing', 'VBG'),
                                           ('need', 'VB'),
                                           ('developing', 'VBG'),
                                           ('wind', 'VB'),
                                           ('be', 'VB'),
                                           ('had', 'VBD'),
                                           ('build', 'VB'),
                                           ('had', 'VBD'),
                                           ('decide', 'VB'),
                                           ('use', 'VB'),
                                           ('s', 'VB'),
                                           ('use', 'VB'),
                                           ('wasting', 'VBG'),
                                           ('evaluating', 'VBG'),
                                           ('<', 'VB'),
                                           ('<', 'VB'),
                                           ('don', 'VB'),
                                           ('develop', 'VB'),
                                           ('make', 'VB'),
                                           ('re', 'VB'),
                                           ('fail', 'VB'),
                                           ('s', 'VB'),
                                           ('change', 'VB'),
                                           ('have', 'VB'),
                                           ('developing', 'VBG'),
                                           ('do', 'VB'),
                                           ('recognize', 'VB'),
                                           ('isn', 'VB'),
                                           ('won', 'VBD'),
                                           ('<', 'VB'),
                                           ('hit', 'VBD'),
                                           ('scaling', 'VBG'),
                                           ('interfacing', 'VBG'),
                                           ('finding', 'VBG'),
                                           ('understand', 'VB'),
                                           ('re', 'VB'),
                                           ('making', 'VBG'),
                                           ('making', 'VBG'),
                                           ('be', 'VB'),
                                           ('be', 'VB'),
                                           ('buying', 'VBG'),
                                           ('get', 'VB'),
                                           ('risk', 'VB'),
                                           ('Going', 'VBG'),
                                           ('Get', 'VB'),
                                           ('cross', 'VB'),
                                           ('interesting', 'VBG'),
                                           ('<', 'VBG'),
                                           ('told', 'VBD'),
                                           ('made', 'VBD'),
                                           ('made', 'VBD'),
                                           ('made', 'VBD'),
                                           ('<', 'VB'),
                                           ('believed', 'VBD'),
                                           ('won', 'VBD'),
                                           ('>', 'VBD'),
                                           ('being', 'VBG'),
                                           ('building', 'VBG'),
                                           ('have', 'VB'),
                                           ('decide', 'VB'),
                                           ('re', 'VB'),
                                           ('going', 'VBG'),
                                           ('be', 'VB'),
                                           ('ended', 'VBD'),
                                           ('doing', 'VBG'),
                                           ('was', 'VBD'),
                                           ('telling', 'VBG'),
                                           ('had', 'VBD'),
                                           ('build', 'VB'),
                                           ('wrote', 'VBD'),
                                           ('had', 'VBD'),
                                           ('know', 'VB'),
                                           ('avoid', 'VB'),
                                           ('knew', 'VBD'),
                                           ('avoid', 'VB'),
                                           ('have', 'VB'),
                                           ('did', 'VBD'),
                                           ('architecting', 'VBG'),
                                           ('begin', 'VB'),
                                           ('get', 'VB'),
                                           ('was', 'VBD'),
                                           ('was', 'VBD'),
                                           ('debating', 'VBG'),
                                           ('programming', 'VBG'),
                                           ('mentioned', 'VBD'),
                                           ('<', 'VB'),
                                           ('be', 'VB'),
                                           ('developing', 'VBG'),
                                           ('<', 'VB'),
                                           ('>', 'VB')]}
        # print(result)
        self.assertEqual(result, expected_result)
