1 '''
2 This module is meant for testing the class C{Excursion}.
3 It only contains a C{main} function.
4
5 Created on Aug 26, 2011
6
7 @author: santtu
8 '''
9 from student import Student
10 from excursion import Excursion
11
13 '''
14 This main function makes use of various methods in
15 class C{Excursion}.
16 '''
17
18 print 'Creating a bunch of students.'
19 a = Student('Allu', 2)
20 b = Student('Billy', 3)
21 c = Student('Camilla', 2)
22 d = Student('Diana', 1)
23 e = Student('Eetu', 1)
24 f = Student('Frank', 3)
25 g = Student('Geoff', 3)
26 h = Student('Helena', 3)
27 i = Student('Ilpo', 1)
28 j = Student('Johanna', 2)
29 print 'Creating an excursion.'
30 test_trip = Excursion('Minitrip', 1, 4)
31 print '\n' + test_trip.get_participant_listing() + '\n'
32
33 print 'Signing up some people.'
34 test_trip.sign_up(a)
35 test_trip.sign_up(b)
36 test_trip.sign_up(c)
37 print '\n' + test_trip.get_participant_listing() + '\n'
38
39 print 'Signing up some more people.'
40 test_trip.sign_up(d)
41 test_trip.sign_up(e)
42 test_trip.sign_up(f)
43 test_trip.sign_up(g)
44 test_trip.sign_up(h)
45 test_trip.sign_up(i)
46 print '\n' + test_trip.get_participant_listing() + '\n'
47
48 print 'Adding places.'
49 test_trip.add_places(2)
50 print '\n' + test_trip.get_participant_listing() + '\n'
51
52 print 'Testing has_places() and get_reserve_position() with various people:'
53 print b.get_name() + ': '+ str(test_trip.has_place(b)) + ', ' + str(test_trip.get_reserve_position(b))
54 print g.get_name() + ': '+ str(test_trip.has_place(g)) + ', ' + str(test_trip.get_reserve_position(g))
55 print h.get_name() + ': '+ str(test_trip.has_place(h)) + ', ' + str(test_trip.get_reserve_position(h))
56 print j.get_name() + ': '+ str(test_trip.has_place(j)) + ', ' + str(test_trip.get_reserve_position(j))
57
58 print '\nList of reserves, in order: '
59 reserves = test_trip.get_reserves()
60 if len(reserves) == 0:
61 print ' (no reserves)'
62 else:
63 for current in test_trip.get_reserves():
64 print current.get_description()
65
66 print '\nRedoing excursion. Here are the two resulting participant listings:'
67 another_trip = test_trip.redo(5)
68 print '\n' + test_trip.get_participant_listing()
69 print '\n' + another_trip.get_participant_listing() + '\n'
70
71
72
73
74
75
76
77 if __name__ == '__main__':
78 main()
79