1 # ###################################################
2 # Copyright (C) 2008 The OpenAnno Team
4 # This file is part of OpenAnno.
6 # OpenAnno is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 # ###################################################
23 from storage
import Storage
25 print "This test has to ne run in the folder where storage.py is."
26 storage
= Storage(5, 40)
28 print "Test1 - Adding 4 ressources with various amounts"
31 res
= storage
.alter_inventory(i
, i
*10)
34 print "Adding res %i with amount %i success" % (i
, i
*10)
37 print "Adding res %i with amount %i failed" % (i
, i
*10)
38 print "Test1 passed" if test
else "Test1 failed"
40 print "Test2 - Adding 1 ressource with an amount over maximum"
42 res
= storage
.alter_inventory(5, 50)
44 print "Adding res %i with amount %i successfully returned 10" % (5, 50)
47 print "Adding res %i with amount %i failed to return 10" % (5, 50)
48 print "Test2 passed" if test
else "Test2 failed"
50 print "Test3 - Adding a ressource that is not in the inventory, but inventory is full."
52 res
= storage
.alter_inventory(6, 30)
54 print "Adding res %i with amount %i successfull returned None" % (6, 30)
57 print "Adding res %i with amount %i failed to return None" % (6, 30)
58 print "Test3 passed" if test
else "Test3 failed"
60 print "Test4 - Adding a ressource that is in the inventory allready."
62 res
= storage
.alter_inventory(1, 10)
64 print "Adding res %i with amount %i successfull." % (1, 10)
67 print "Adding res %i with amount %i failed." % (1, 10)
68 res
= storage
.alter_inventory(2, 30)
70 print "Adding res %i with amount %i successfull." % (2, 20)
73 print "Adding res %i with amount %i failed." % (2, 20)
74 print "Test4 passed" if test
else "Test4 failed"
76 print "Test5 - Adding a ressource that is in the inventory allready."
78 res
= storage
.alter_inventory(1, -10)
80 print "Adding res %i with amount %i successfull." % (1, -10)
83 print "Adding res %i with amount %i failed." % (1, -10)
84 res
= storage
.alter_inventory(2, -70)
86 print "Adding res %i with amount %i successfull." % (2, -70)
89 print "Adding res %i with amount %i failed." % (2, -70)
90 print "Test5 passed" if test
else "Test5 failed"
92 print storage
.inventory