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

import pdb

import logging        as mod_logging
import srtm           as mod_srtm

if __name__ == '__main__':
    mod_logging.basicConfig(level = mod_logging.DEBUG, format = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s')

    get_data = mod_srtm.get_data()

    print 'Should be 61:', get_data.get_elevation(46., 13.)
    print 'Should be 2700:', get_data.get_elevation(46.999999, 13.)
    print 'Should be 1622:', get_data.get_elevation(46.999999, 13.999999)
    print 'Should be 544:', get_data.get_elevation(46., 13.999999)
    print 'Višnjan:', get_data.get_elevation(45.2732, 13.7139)
    print 'Pilošćak:', get_data.get_elevation(45.287, 13.905)
    print 'Invalid SRTM point:', get_data.get_elevation(47.0, 13.07)
<commit_msg>Tests<commit_after># -*- coding: utf-8 -*-

"""
Run all tests with:
    $ python -m unittest test
"""

import pdb

import logging        as mod_logging
import unittest as mod_unittest
import srtm           as mod_srtm

mod_logging.basicConfig(level=mod_logging.DEBUG,
                        format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s')

class LxmlTests(mod_unittest.TestCase):

    def test_random_points(self):
        geo_elevation_data = mod_srtm.get_data()
        self.assertEquals(63, geo_elevation_data.get_elevation(46., 13.))
        self.assertEquals(2714, geo_elevation_data.get_elevation(46.999999, 13.))
        self.assertEquals(1643, geo_elevation_data.get_elevation(46.999999, 13.999999))
        self.assertEquals(553, geo_elevation_data.get_elevation(46., 13.999999))
        self.assertEquals(203, geo_elevation_data.get_elevation(45.2732, 13.7139))
        self.assertEquals(460, geo_elevation_data.get_elevation(45.287, 13.905))

    def test_around_zero_longitude(self):
        geo_elevation_data = mod_srtm.get_data()
        self.assertEquals(61, geo_elevation_data.get_elevation(51.2, 0.0))
        self.assertEquals(100, geo_elevation_data.get_elevation(51.2, -0.1))
        self.assertEquals(59, geo_elevation_data.get_elevation(51.2, 0.1))

    def test_around_zero_latitude(self):
        geo_elevation_data = mod_srtm.get_data()
        self.assertEquals(393, geo_elevation_data.get_elevation(0, 15))
        self.assertEquals(423, geo_elevation_data.get_elevation(-0.1, 15))
        self.assertEquals(381, geo_elevation_data.get_elevation(0.1, 15))

    def test_point_with_invalid_elevation(self):
        geo_elevation_data = mod_srtm.get_data()
        self.assertEquals(None, geo_elevation_data.get_elevation(47.0, 13.07))

    def test_point_without_file(self):
        geo_elevation_data = mod_srtm.get_data()
        print geo_elevation_data.get_elevation(0, 0)

{'fraction_non_alphanumeric': 0.12180673824509441, 'fraction_numerical': 0.0821917808219178, 'mean_word_length': 3.850987432675045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '4747432', 'n_tokens_mistral': 1184, 'n_tokens_neox': 978, 'n_words': 157}