<s> import sys <EOL> import unittest <EOL> from datetime import datetime , timedelta <EOL> from flask . ext . sqlalchemy import BaseQuery <EOL> from controller import c3bottles , db <EOL> from model . drop_point import DropPoint <EOL> from model . location import Location <EOL> from model . capacity import Capacity <EOL> from model . report import Report <EOL> from model . visit import Visit <EOL> print ( "<STR_LIT>" % ( sys . version_info [ <NUM_LIT:0> ] , sys . version_info [ <NUM_LIT:1> ] ) ) <EOL> def load_config ( ) : <EOL> c3bottles . config [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> c3bottles . config [ '<STR_LIT>' ] = True <EOL> class C3bottlesModelTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> load_config ( ) <EOL> self . c3bottles = c3bottles . test_client ( ) <EOL> db . create_all ( ) <EOL> def tearDown ( self ) : <EOL> db . session . remove ( ) <EOL> db . drop_all ( ) <EOL> def test_drop_point_construction ( self ) : <EOL> dp_number = <NUM_LIT:1> <EOL> time = datetime . today ( ) - timedelta ( hours = <NUM_LIT:1> ) <EOL> description = "<STR_LIT>" <EOL> lat = <NUM_LIT:20> <EOL> lng = <NUM_LIT:10> <EOL> level = <NUM_LIT:2> <EOL> crate_count = <NUM_LIT:3> <EOL> dp = DropPoint ( <EOL> dp_number , <EOL> time = time , <EOL> description = description , <EOL> lat = lat , <EOL> lng = lng , <EOL> level = level , <EOL> crates = crate_count <EOL> ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> db . session . query ( DropPoint ) . get ( dp_number ) , dp , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . number , dp_number , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertFalse ( <EOL> dp . removed , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertIsInstance ( <EOL> dp . reports , BaseQuery , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertFalse ( <EOL> dp . reports . all ( ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertIsInstance ( <EOL> dp . visits , BaseQuery , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertFalse ( <EOL> dp . visits . all ( ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertIsInstance ( <EOL> dp . locations [ <NUM_LIT:0> ] , Location , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertIsInstance ( <EOL> dp . capacities [ <NUM_LIT:0> ] , Capacity , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . time , time , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . locations [ <NUM_LIT:0> ] . description , description , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . locations [ <NUM_LIT:0> ] . lat , lat , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . locations [ <NUM_LIT:0> ] . lng , lng , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . locations [ <NUM_LIT:0> ] . level , level , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . locations [ <NUM_LIT:0> ] . time , time , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_current_crate_count ( ) , crate_count , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . capacities [ <NUM_LIT:0> ] . crates , crate_count , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . capacities [ <NUM_LIT:0> ] . time , time , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_drop_point_construction_exceptions ( self ) : <EOL> dp_number = <NUM_LIT:1> <EOL> DropPoint ( dp_number , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> db . session . commit ( ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> DropPoint ( dp_number , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> numbers = ( - <NUM_LIT:1> , "<STR_LIT:foo>" , None ) <EOL> for num in numbers : <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> DropPoint ( num , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> time_in_future = datetime . today ( ) + timedelta ( hours = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> DropPoint ( dp_number , time = time_in_future , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> DropPoint ( dp_number , time = "<STR_LIT:foo>" , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> def test_drop_point_getters ( self ) : <EOL> dp_number = <NUM_LIT:1> <EOL> time = datetime . today ( ) <EOL> dp = DropPoint ( <EOL> dp_number , <EOL> time = time , <EOL> lat = <NUM_LIT:0> , <EOL> lng = <NUM_LIT:0> , <EOL> level = <NUM_LIT:1> <EOL> ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> DropPoint . get ( dp_number ) , dp , <EOL> "<STR_LIT>" <EOL> ) <EOL> wrong_numbers = ( dp_number + <NUM_LIT:1> , - <NUM_LIT:1> , "<STR_LIT:foo>" , None ) <EOL> for number in wrong_numbers : <EOL> self . assertIsNone ( <EOL> DropPoint . get ( number ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertIsInstance ( <EOL> dp . get_current_location ( ) , Location , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_current_crate_count ( ) , Capacity . default_crate_count , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_last_state ( ) , Report . states [ <NUM_LIT:1> ] , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_total_report_count ( ) , <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_new_report_count ( ) , <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertFalse ( <EOL> dp . get_last_visit ( ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertFalse ( <EOL> dp . get_last_report ( ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertFalse ( <EOL> dp . get_new_reports ( ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertGreater ( <EOL> dp . get_visit_interval ( ) , <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertIsInstance ( <EOL> dp . get_history ( ) , list , <EOL> "<STR_LIT>" <EOL> ) <EOL> for elem in dp . get_history ( ) : <EOL> self . assertIsInstance ( <EOL> elem , dict , <EOL> "<STR_LIT>" <EOL> ) <EOL> assumed_history_length = <NUM_LIT:3> <EOL> self . assertEqual ( <EOL> len ( dp . get_history ( ) ) , assumed_history_length , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertIsInstance ( <EOL> DropPoint . get_dps_json ( ) , str , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertGreater ( <EOL> len ( DropPoint . get_dps_json ( ) ) , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> DropPoint . get_dps_json ( datetime . today ( ) ) , "<STR_LIT:{}>" , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> DropPoint . get_dps_json ( datetime . today ( ) ) , "<STR_LIT:{}>" , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> DropPoint . get_dps_json ( time ) , "<STR_LIT:{}>" , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertNotEqual ( <EOL> DropPoint . get_dps_json ( time - timedelta ( seconds = <NUM_LIT:1> ) ) , "<STR_LIT:{}>" , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_location_addition_to_drop_point ( self ) : <EOL> dp_number = <NUM_LIT:3> <EOL> first_description = "<STR_LIT>" <EOL> first_lat = - <NUM_LIT> <EOL> first_lng = <NUM_LIT> <EOL> first_level = <NUM_LIT:3> <EOL> second_description = "<STR_LIT>" <EOL> second_lat = <NUM_LIT> <EOL> second_lng = - <NUM_LIT> <EOL> second_level = <NUM_LIT:2> <EOL> first_time = datetime . today ( ) - timedelta ( hours = <NUM_LIT:2> ) <EOL> second_time = datetime . today ( ) - timedelta ( hours = <NUM_LIT:2> - <NUM_LIT:1> ) <EOL> dp = DropPoint ( <EOL> dp_number , <EOL> description = first_description , <EOL> lat = first_lat , <EOL> lng = first_lng , <EOL> level = first_level , <EOL> time = first_time <EOL> ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> len ( dp . locations ) , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> db . session . query ( Location ) . count ( ) , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> ) <EOL> second_location = Location ( <EOL> dp , <EOL> description = second_description , <EOL> lat = second_lat , <EOL> lng = second_lng , <EOL> level = second_level , <EOL> time = second_time <EOL> ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> len ( dp . locations ) , <NUM_LIT:2> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> db . session . query ( Location ) . count ( ) , <NUM_LIT:2> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_current_location ( ) , second_location , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . locations [ <NUM_LIT:1> ] . time - <EOL> dp . locations [ <NUM_LIT:0> ] . time , <EOL> second_time - first_time , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_location_construction_exceptions ( self ) : <EOL> dp = DropPoint ( <NUM_LIT:1> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Location ( "<STR_LIT:foo>" ) <EOL> time_in_future = datetime . today ( ) + timedelta ( hours = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Location ( dp , time = time_in_future , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Location ( dp , time = "<STR_LIT:foo>" , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> start_time = datetime . today ( ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Location ( dp , time = start_time , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> db . session . commit ( ) <EOL> Location ( dp , time = start_time - timedelta ( hours = <NUM_LIT:1> ) ) <EOL> invalid_lat = ( "<STR_LIT:foo>" , - <NUM_LIT> , <NUM_LIT> , None ) <EOL> invalid_lng = ( "<STR_LIT:bar>" , - <NUM_LIT> , <NUM_LIT> , None ) <EOL> invalid_level = ( "<STR_LIT>" , None ) <EOL> for lat in invalid_lat : <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Location ( dp , lat = lat , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> for lng in invalid_lng : <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Location ( dp , lat = <NUM_LIT:0> , lng = lng , level = <NUM_LIT:1> ) <EOL> for level in invalid_level : <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Location ( dp , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = level ) <EOL> too_long = "<STR_LIT:a>" * ( Location . max_description + <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Location ( dp , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> , description = too_long ) <EOL> def test_capacity_addition_to_drop_point ( self ) : <EOL> dp_number = <NUM_LIT:3> <EOL> first_crate_count = <NUM_LIT:5> <EOL> second_crate_count = <NUM_LIT:2> <EOL> first_time = datetime . today ( ) - timedelta ( hours = <NUM_LIT:2> ) <EOL> second_time = datetime . today ( ) - timedelta ( hours = <NUM_LIT:2> - <NUM_LIT:1> ) <EOL> dp = DropPoint ( <EOL> dp_number , <EOL> crates = first_crate_count , <EOL> time = first_time , <EOL> lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> <EOL> ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> len ( dp . capacities ) , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> db . session . query ( Capacity ) . count ( ) , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> ) <EOL> second_capacity = Capacity ( <EOL> dp , <EOL> crates = second_crate_count , <EOL> time = second_time <EOL> ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> len ( dp . capacities ) , <NUM_LIT:2> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> db . session . query ( Capacity ) . count ( ) , <NUM_LIT:2> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . capacities [ - <NUM_LIT:1> ] , second_capacity , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_current_crate_count ( ) , second_crate_count , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . capacities [ <NUM_LIT:1> ] . time - <EOL> dp . capacities [ <NUM_LIT:0> ] . time , <EOL> second_time - first_time , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_capacity_construction ( self ) : <EOL> dp = DropPoint ( <NUM_LIT:1> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> capacity = Capacity ( dp ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> dp . capacities [ - <NUM_LIT:1> ] , capacity , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> capacity . crates , Capacity . default_crate_count , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_capacity_construction_exceptions ( self ) : <EOL> dp = DropPoint ( <NUM_LIT:1> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Capacity ( "<STR_LIT:foo>" ) <EOL> time_in_future = datetime . today ( ) + timedelta ( hours = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Capacity ( dp , time_in_future ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Capacity ( dp , "<STR_LIT:foo>" ) <EOL> start_time = datetime . today ( ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Capacity ( dp , time = start_time ) <EOL> db . session . commit ( ) <EOL> Capacity ( dp , time = start_time - timedelta ( hours = <NUM_LIT:1> ) ) <EOL> invalid_crate_counts = ( - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> for count in invalid_crate_counts : <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT:count>" ) : <EOL> Capacity ( dp , crates = count ) <EOL> def test_drop_point_removal ( self ) : <EOL> dp = DropPoint ( <NUM_LIT:1> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> self . assertFalse ( <EOL> dp . removed , <EOL> "<STR_LIT>" <EOL> ) <EOL> removal_time = datetime . today ( ) <EOL> dp . remove ( time = removal_time ) <EOL> self . assertIsInstance ( <EOL> dp . removed , datetime , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . removed , removal_time , <EOL> "<STR_LIT>" <EOL> ) <EOL> dp = DropPoint ( <NUM_LIT:2> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> dp . remove ( ) <EOL> self . assertIsInstance ( <EOL> dp . removed , datetime , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_priority ( ) , <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_drop_point_removal_exceptions ( self ) : <EOL> dp = DropPoint ( <NUM_LIT:1> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> time_in_future = datetime . today ( ) + timedelta ( hours = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> dp . remove ( time_in_future ) <EOL> with self . assertRaisesRegexp ( TypeError , "<STR_LIT>" ) : <EOL> dp . remove ( "<STR_LIT:foo>" ) <EOL> with self . assertRaisesRegexp ( RuntimeError , "<STR_LIT>" ) : <EOL> dp . remove ( ) <EOL> dp . remove ( ) <EOL> def test_drop_point_reporting ( self ) : <EOL> states = Report . states <EOL> dp = DropPoint ( <NUM_LIT:1> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> first_time = datetime . today ( ) <EOL> first_state = states [ <NUM_LIT:0> ] <EOL> first_report = Report ( dp , state = first_state , time = first_time ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> first_report . time , first_time , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> first_report . state , first_state , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . reports [ <NUM_LIT:0> ] , first_report , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_last_report ( ) , first_report , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_last_state ( ) , first_state , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_total_report_count ( ) , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_new_report_count ( ) , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_new_reports ( ) [ <NUM_LIT:0> ] , first_report , <EOL> "<STR_LIT>" <EOL> ) <EOL> second_time = datetime . today ( ) <EOL> second_state = states [ - <NUM_LIT:1> ] <EOL> second_report = Report ( dp , state = second_state , time = second_time ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> second_report . state , second_state , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . reports [ - <NUM_LIT:1> ] , second_report , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_last_report ( ) , second_report , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_last_state ( ) , second_state , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_total_report_count ( ) , <NUM_LIT:2> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_new_report_count ( ) , <NUM_LIT:2> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_new_reports ( ) [ <NUM_LIT:0> ] , second_report , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_report_construction_exceptions ( self ) : <EOL> states = Report . states <EOL> dp = DropPoint ( <NUM_LIT:1> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Report ( None ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT:state>" ) : <EOL> Report ( dp ) <EOL> time_in_future = datetime . today ( ) + timedelta ( hours = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Report ( dp , time = time_in_future , state = states [ <NUM_LIT:0> ] ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Report ( dp , time = "<STR_LIT:foo>" , state = states [ <NUM_LIT:0> ] ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT:state>" ) : <EOL> Report ( dp , state = "<STR_LIT>" ) <EOL> def test_report_weight_calculation ( self ) : <EOL> pass <EOL> def test_drop_point_visiting ( self ) : <EOL> actions = Visit . actions <EOL> dp = DropPoint ( <NUM_LIT:1> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> first_time = datetime . today ( ) <EOL> first_action = actions [ <NUM_LIT:1> ] <EOL> first_visit = Visit ( dp , action = first_action , time = first_time ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> first_visit . time , first_time , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> first_visit . action , first_action , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . visits [ <NUM_LIT:0> ] , first_visit , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_last_visit ( ) , first_visit , <EOL> "<STR_LIT>" <EOL> ) <EOL> report_time = datetime . today ( ) <EOL> report_state = Report . states [ <NUM_LIT:0> ] <EOL> report = Report ( dp , state = report_state , time = report_time ) <EOL> second_time = datetime . today ( ) <EOL> second_action = actions [ <NUM_LIT:0> ] <EOL> second_visit = Visit ( dp , action = second_action , time = second_time ) <EOL> db . session . commit ( ) <EOL> self . assertEqual ( <EOL> second_visit . action , second_action , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . visits [ - <NUM_LIT:1> ] , second_visit , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_last_visit ( ) , second_visit , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertNotEqual ( <EOL> dp . get_last_state ( ) , report_state , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_new_report_count ( ) , <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertFalse ( <EOL> dp . get_new_reports ( ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_last_report ( ) , report , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> dp . get_total_report_count ( ) , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_visit_construction_exceptions ( self ) : <EOL> actions = Visit . actions <EOL> dp = DropPoint ( <NUM_LIT:1> , lat = <NUM_LIT:0> , lng = <NUM_LIT:0> , level = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Visit ( None ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT:action>" ) : <EOL> Visit ( dp ) <EOL> time_in_future = datetime . today ( ) + timedelta ( hours = <NUM_LIT:1> ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Visit ( dp , time = time_in_future , action = actions [ <NUM_LIT:0> ] ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT>" ) : <EOL> Visit ( dp , time = "<STR_LIT:foo>" , action = actions [ <NUM_LIT:0> ] ) <EOL> with self . assertRaisesRegexp ( ValueError , "<STR_LIT:action>" ) : <EOL> Visit ( dp , action = "<STR_LIT>" ) <EOL> def test_drop_point_visit_priority_calculation ( self ) : <EOL> pass <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
