summaryrefslogtreecommitdiffstats
path: root/funcweb/funcweb/tests
diff options
context:
space:
mode:
authormakkalot <makkalot@gmail.com>2008-07-18 21:01:49 +0300
committermakkalot <makkalot@gmail.com>2008-07-18 21:01:49 +0300
commitee28acfac71b5132fbdca9fb85fcce099cbafce2 (patch)
tree5e5884fc862af4b4680e9f5c4daeff67bf87839a /funcweb/funcweb/tests
parent97bb5b94f1dd77caf13af6c99b7852995f039428 (diff)
downloadfunc-ee28acfac71b5132fbdca9fb85fcce099cbafce2.tar.gz
func-ee28acfac71b5132fbdca9fb85fcce099cbafce2.tar.xz
func-ee28acfac71b5132fbdca9fb85fcce099cbafce2.zip
go go tester :)
Diffstat (limited to 'funcweb/funcweb/tests')
-rw-r--r--funcweb/funcweb/tests/test_async_tools.py90
1 files changed, 81 insertions, 9 deletions
diff --git a/funcweb/funcweb/tests/test_async_tools.py b/funcweb/funcweb/tests/test_async_tools.py
index 4296a9e..5e7b944 100644
--- a/funcweb/funcweb/tests/test_async_tools.py
+++ b/funcweb/funcweb/tests/test_async_tools.py
@@ -1,29 +1,87 @@
from funcweb.async_tools import AsyncResultManager
from func.overlord.client import Overlord
+from func.jobthing import *
import unittest
-class TestAsyncResultManager(unittest.TestCase):
+class AsyncResultManagerTest(object):
def setUp(self):
self.fc = Overlord("*")
self.async_manager = AsyncResultManager()
- def test_get_current_list(self):
+ def get_current_list_test(self):
+ #that is tested in test_current_db
pass
- def test_update_current_list(self):
+ def update_current_list_test(self):
pass
+
- def test_check_for_changes(self):
+ def check_for_changes_test(self):
+
+ #first reset the database to see what is there
+ self.remove_db()
+ #all of them are new now
+ self.async_manager.reset_current_list()
+ #now make a new entry into database to have a only one
+ #new entry in the db ...
+ #running a new command which is a short one
+ new_fc = Overlord("*",async=True)
+ new_job_id=new_fc.test.add(1,2)
+ #print "The job id we got is :",new_job_id
+ changes = self.async_manager.check_for_changes()
+ print "The latest Changes for add method are :",changes
+ assert len(changes) == 1
+ assert changes[0] == new_job_id
+
+ #check if that one is finished
+ another_test = False
+ while new_fc.job_status(new_job_id)[0] != JOB_ID_FINISHED:
+ print "Waiting for add command to finish "
+ time.sleep(2)
+ another_test = True
+
+ # that probably may happen so should add it here
+ if another_test:
+ changes = self.async_manager.check_for_changes()
+ assert len(changes) == 1
+ assert changes[0] == new_job_id
+ print "The changes are for add finish :",changes
+
+ #now should run another command that is longer to see what happens
+ new_job_id = new_fc.test.sleep(4)
+ # we have now one entry in the db what to do ?
+ # when now run the check changes should have ne entry in the changes :)
+ changes = self.async_manager.check_for_changes()
+ print "The changes for sleep are :",changes
+ assert len(changes) == 1
+ assert changes[0] == new_job_id
+
+ #if we already have the finished message we dont have to run the other test after that one
+ another_test = False
+ while new_fc.job_status(new_job_id)[0] != JOB_ID_FINISHED:
+ print "Waiting for sleep command to finish "
+ time.sleep(2)
+ another_test = True
+
+ if another_test:
+ changes = self.async_manager.check_for_changes()
+ assert len(changes) == 1
+ assert changes[0] == new_job_id
+ print "The changes for sleep finish are :",changes
+
+
+ def select_from_test(self):
pass
+ #insert one running
+ #insert one that finishes
+ #insert one raises error
+ #insert one another
- def test_select_from(self):
+ def job_id_result_test(self):
pass
- def test_job_id_result(self):
- pass
-
- def test_current_db(self):
+ def current_db_test(self):
#that test also test the test_get_current_list with no changes option
result_ids = self.fc.open_job_ids()
@@ -35,4 +93,18 @@ class TestAsyncResultManager(unittest.TestCase):
#print real_result
assert manual_list ==real_result
+ def remove_db(self):
+ import os
+ root_dir = "/var/lib/func"
+ db_file_list = os.listdir(root_dir)
+ for f in db_file_list:
+ if not f.startswith("."):
+ os.remove("".join([root_dir,"/",f]))
+
+ print "The database is removed"
+# we do it that way because when run it from nosetest we hae failings
+tester = AsyncResultManagerTest()
+tester.setUp()
+#tester.current_db_test()
+tester.check_for_changes_test()