SF.net SVN: fclient: [166] trunk/sandbox/fcp/test_fcp/test_fcp2_0_client.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <ju...@us...> - 2008-02-06 14:57:29
|
Revision: 166
http://fclient.svn.sourceforge.net/fclient/?rev=166&view=rev
Author: jurner
Date: 2008-02-06 06:57:28 -0800 (Wed, 06 Feb 2008)
Log Message:
-----------
distinguish Removed from RemovedFromQueue
Modified Paths:
--------------
trunk/sandbox/fcp/test_fcp/test_fcp2_0_client.py
Modified: trunk/sandbox/fcp/test_fcp/test_fcp2_0_client.py
===================================================================
--- trunk/sandbox/fcp/test_fcp/test_fcp2_0_client.py 2008-02-06 14:57:08 UTC (rev 165)
+++ trunk/sandbox/fcp/test_fcp/test_fcp2_0_client.py 2008-02-06 14:57:28 UTC (rev 166)
@@ -542,7 +542,8 @@
('FcStatus', consts.RequestStatus.Pending |
consts.RequestStatus.Started |
consts.RequestStatus.Success |
- consts.RequestStatus.Removed),
+ consts.RequestStatus.RemovedFromQueue
+ ),
data=data
)
self.failIf(myIdentifier in allRequests)
@@ -554,8 +555,8 @@
allRequests[myIdentifier] =myRequest
myRequest['Persistence'] = consts.Persistence.Forever
myRequest['FcStatus'] &= ~(consts.RequestStatus.Success |
- consts.RequestStatus.Removed |
- consts.RequestStatus.Completed
+ consts.RequestStatus.Completed |
+ consts.RequestStatus.RemovedFromQueue
)
self.sendResponseMessage(
'AllData',
@@ -617,7 +618,8 @@
('FcStatus', consts.RequestStatus.Pending |
consts.RequestStatus.Started |
consts.RequestStatus.Error |
- consts.RequestStatus.Removed)
+ consts.RequestStatus.RemovedFromQueue
+ )
)
self.failUnless(myRequest['FcStatus'] & consts.RequestStatus.Completed)
self.assertHasNextEvent(None)
@@ -629,8 +631,9 @@
allRequests[myIdentifier] =myRequest
myRequest['Persistence'] = consts.Persistence.Forever
myRequest['FcStatus'] &= ~(consts.RequestStatus.Error |
- consts.RequestStatus.Removed |
- consts.RequestStatus.Completed)
+ consts.RequestStatus.Completed |
+ consts.RequestStatus.RemovedFromQueue
+ )
self.sendResponseMessage(
'GetFailed',
Code='28', # All data not found
@@ -693,7 +696,11 @@
self.assertHasNextEvent(
self.fcpClient.events.RequestCompleted,
consts.Message.ClientGet,
- ('FcStatus', consts.RequestStatus.Pending | consts.RequestStatus.Started | consts.RequestStatus.Success | consts.RequestStatus.Removed)
+ ('FcStatus', consts.RequestStatus.Pending |
+ consts.RequestStatus.Started |
+ consts.RequestStatus.Success |
+ consts.RequestStatus.RemovedFromQueue
+ )
)
self.failIf(myIdentifier in allRequests)
self.failUnless(myRequest['FcStatus'] & consts.RequestStatus.Completed)
@@ -736,7 +743,11 @@
self.assertHasNextEvent(
self.fcpClient.events.RequestFailed,
consts.Message.ClientGet,
- ('FcStatus', consts.RequestStatus.Pending | consts.RequestStatus.Started | consts.RequestStatus.Error | consts.RequestStatus.Removed)
+ ('FcStatus', consts.RequestStatus.Pending |
+ consts.RequestStatus.Started |
+ consts.RequestStatus.Error |
+ consts.RequestStatus.RemovedFromQueue
+ )
)
self.failIf(myIdentifier in allRequests)
self.failUnless(myRequest['FcStatus'] & consts.RequestStatus.Completed)
@@ -748,7 +759,6 @@
# request a arbitrary uri
myIdentifier = self.fcpClient.getKeyInfo(
'arbitrary-uri',
- persistence=consts.Persistence.Forever, # cheat a bit, so we can test multiple cases
)
myRequest = self.fcpClient.getRequest(myIdentifier)
allRequests = self.fcpClient.getRequests()
@@ -783,15 +793,44 @@
self.assertHasNextEvent(
self.fcpClient.events.RequestCompleted,
consts.Message.ClientGet,
- ('FcStatus', consts.RequestStatus.Pending | consts.RequestStatus.Started | consts.RequestStatus.Success)
+ ('FcStatus', consts.RequestStatus.Pending |
+ consts.RequestStatus.Started |
+ consts.RequestStatus.Success |
+ consts.RequestStatus.RemovedFromQueue
+ )
)
- self.failIf(myIdentifier not in allRequests)
+ self.failIf(myIdentifier in allRequests)
self.failUnless(myRequest['FcStatus'] & consts.RequestStatus.Completed)
self.assertHasNextEvent(None)
+
+ def testGetKeyInfo_TooBig(self):
+
# test specdial case where ProtocolError.TooBig is handled as success
- myRequest['FcStatus'] &= ~(consts.RequestStatus.Success)
+ # request a arbitrary uri
+ myIdentifier = self.fcpClient.getKeyInfo(
+ 'arbitrary-uri',
+ )
+ myRequest = self.fcpClient.getRequest(myIdentifier)
+ allRequests = self.fcpClient.getRequests()
+
+ self.assertHasNextMessage(consts.Message.ClientGet)
+
+ # respond to the file request
self.sendResponseMessage(
+ 'PersistentGet',
+ Started='false',
+ **myRequest.params
+ )
+ self.assertHasNextEvent(
+ self.fcpClient.events.RequestStarted,
+ consts.Message.ClientGet,
+ ('FcStatus', consts.RequestStatus.Pending | consts.RequestStatus.Started)
+ )
+ self.assertHasNextEvent(None)
+
+ # finalize request
+ self.sendResponseMessage(
'GetFailed',
Code='21', # Too big
Identifier=myIdentifier,
@@ -803,8 +842,8 @@
consts.Message.ClientGet,
('FcStatus', consts.RequestStatus.Pending |
consts.RequestStatus.Started |
- consts.RequestStatus.Success |
- consts.RequestStatus.Completed
+ consts.RequestStatus.Success |
+ consts.RequestStatus.RemovedFromQueue
)
)
self.failUnless(myRequest['FcStatus'] & consts.RequestStatus.Completed)
@@ -814,10 +853,7 @@
myRequest['Persistence'] = consts.Persistence.Connection
myRequest['FcStatus'] = consts.RequestStatus.Started
- ###########################################
- ###########################################
-
-
+
def testGetKeyInfo_Failure(self):
# request a arbitrary file
@@ -851,7 +887,11 @@
self.assertHasNextEvent(
self.fcpClient.events.RequestFailed,
consts.Message.ClientGet,
- ('FcStatus', consts.RequestStatus.Pending | consts.RequestStatus.Started | consts.RequestStatus.Error | consts.RequestStatus.Removed)
+ ('FcStatus', consts.RequestStatus.Pending |
+ consts.RequestStatus.Started |
+ consts.RequestStatus.Error |
+ consts.RequestStatus.RemovedFromQueue
+ )
)
self.failUnless(myRequest['FcStatus'] & consts.RequestStatus.Completed)
self.assertHasNextEvent(None)
@@ -934,7 +974,10 @@
# status of our request should be set to removed emidiately, but it should
# not be removed from the client
- self.assertEqual(myRequest['FcStatus'], consts.RequestStatus.Pending | consts.RequestStatus.Started | consts.RequestStatus.Removed)
+ self.assertEqual(myRequest['FcStatus'], consts.RequestStatus.Pending |
+ consts.RequestStatus.Started |
+ consts.RequestStatus.Removed
+ )
self.failUnless(myIdentifier in self.fcpClient.getRequests())
# client schould send a RemovePersistentRequest
@@ -947,9 +990,9 @@
)
# now the request should have been removed
+ self.failUnless(myRequest['FcStatus'] & consts.RequestStatus.RemovedFromQueue)
+ self.failUnless(myRequest['FcStatus'] & consts.RequestStatus.Completed)
self.failIf(self.fcpClient.getRequests())
-
- # client never sends an event here
self.assertHasNextEvent(None)
#***********************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|