<commit_before>#!/usr/bin/env python
"""
Class: CS361_400, SU2016
Group: Tsunami Alerts

This performs unit tests for TsuShield.py
"""

import TsuShield
from nose.tools import assert_equal
from nose.tools import assert_almost_equal
from nose.tools import assert_not_equal
from nose.tools import assert_raises
from nose.tools import assert_true
from nose.tools import assert_false
from nose.tools import raises
from datetime import datetime
from dateutil.parser import parse

def do_download_happy_path():
    alert = do_download(False)
    assert_not_equal(alert, None)
    response = urllib2.urlopen('http://wcatwc.arh.noaa.gov/events/xml/PAAQCAP.xml')
	assert_equal(alert, response.read())

def do_download_test():
    alert = do_download(True)
    assert_not_equal(alert, None)
    with open(r'testdata/actual_not_expired.xml', 'r') as f:
        assert_equal(alert, f.read())

def test_alert_server_application_happy_path():
    url = 'http://vps54981.vps.ovh.ca:8080/?latitude=54.266701&longitude=-133.066696'
    
    response = urllib2.urlopen(url)
    alert = response.read()
    assert_not_equal(alert, None)
	
def test_alert_server_application_invalid_type():
    url = 'http://vps54981.vps.ovh.ca:8080/?latitude=foo&longitude=bar'
    
    response = urllib2.urlopen(url)
    alert = response.read()
    assert_not_equal(alert, None)
    assert_equal(alert,"Invalid coordinates. Cannot complete request.")<commit_msg>Expanded tests<commit_after>#!/usr/bin/env python
"""
Class: CS361_400, SU2016
Group: Tsunami Alerts

This performs unit tests for TsuShield.py
"""

import TsuShield
from nose.tools import assert_equal
from nose.tools import assert_almost_equal
from nose.tools import assert_not_equal
from nose.tools import assert_raises
from nose.tools import assert_true
from nose.tools import assert_false
from nose.tools import raises
from datetime import datetime
from dateutil.parser import parse

def do_download_happy_path():
    alert = do_download(False)
    assert_not_equal(alert, None)
    response = urllib2.urlopen('http://wcatwc.arh.noaa.gov/events/xml/PAAQCAP.xml')
	assert_equal(alert, response.read())

def do_download_test():
    alert = do_download(True)
    assert_not_equal(alert, None)
    with open(r'testdata/actual_not_expired.xml', 'r') as f:
        assert_equal(alert, f.read())

def test_alert_server_application_happy_path():
    url = 'http://vps54981.vps.ovh.ca:8080/?latitude=54.266701&longitude=-133.066696'
    
    response = urllib2.urlopen(url)
    alert = response.read()
    jsonReply = json.loads(alert)
    assert_not_equal(alert, None)
    assert_not_equal(jsonReply, None)
    assert_not_equal(jsonReply['activeAlert'], None)
    if jsonReply['activeAlert']:
        assert_not_equal(jsonReply['distance'], None)
	
def test_alert_server_application_invalid_type():
    url = 'http://vps54981.vps.ovh.ca:8080/?latitude=foo&longitude=bar'
    
    response = urllib2.urlopen(url)
    alert = response.read()
    assert_not_equal(alert, None)
    assert_equal(alert,"Invalid coordinates. Cannot complete request.")
{'fraction_non_alphanumeric': 0.10622352557836429, 'fraction_numerical': 0.03128054740957967, 'mean_word_length': 4.858778625954199, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7425682', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1016, 'n_words': 212}