CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
conditionUploadTest.UploadTest Class Reference

Public Member Functions

def __init__
 
def log
 
def upload
 

Public Attributes

 db
 
 errors
 
 logFileName
 

Detailed Description

Definition at line 104 of file conditionUploadTest.py.

Constructor & Destructor Documentation

def conditionUploadTest.UploadTest.__init__ (   self,
  db 
)

Member Function Documentation

def conditionUploadTest.UploadTest.log (   self,
  msg 
)

Definition at line 110 of file conditionUploadTest.py.

References conditionUploadTest.UploadTest.logFileName.

Referenced by conditionUploadTest.UploadTest.upload().

111  def log( self, msg ):
112  print msg
113  with open(self.logFileName,'a') as logFile:
114  logFile.write(msg)
115  logFile.write('\n')
def conditionUploadTest.UploadTest.upload (   self,
  inputTag,
  baseFile,
  destTag,
  synchro,
  destSince,
  success,
  expectedAction 
)

Definition at line 116 of file conditionUploadTest.py.

References conditionUploadTest.UploadTest.errors, conditionUploadTest.UploadTest.log(), conditionUploadTest.UploadTest.logFileName, conditionUploadTest.makeMetadataFile(), and conditionUploadTest.uploadFile().

117  def upload( self, inputTag, baseFile, destTag, synchro, destSince, success, expectedAction ):
118  insertedSince = None
119  destFile = '%s.db' %destTag
120  metaDestFile = '%s.txt' %destTag
121  shutil.copyfile( baseFile, destFile )
122  self.log( '# ---------------------------------------------------------------------------')
123  self.log( '# Testing tag %s with synch=%s, destSince=%s - expecting ret=%s action=%s' %(destTag,synchro,destSince,success,expectedAction))
124 
125  descr = 'Testing conditionsUpload with synch:%s - expected action: %s' %(synchro,expectedAction)
126  makeMetadataFile( inputTag, destTag, destSince, descr )
127  beforeUpload = datetime.datetime.utcnow()
128  ret = uploadFile( destFile, self.logFileName )
129  if ret != success:
130  self.log( 'ERROR: the return value for the upload of tag %s with sychro %s was %s, while the expected result is %s' %(destTag,synchro,ret,success))
131  self.errors += 1
132  else:
133  row = self.db.getLastInsertedSince( destTag, beforeUpload )
134  if ret == True:
135  if expectedAction == 'CREATE' or expectedAction == 'INSERT' or expectedAction == 'APPEND':
136  if destSince != row[0]:
137  self.log( 'ERROR: the since inserted is %s, expected value is %s - expected action: %s' %(row[0],destSince,expectedAction))
138  self.errors += 1
139  else:
140  self.log( '# OK: Found expected value for last since inserted: %s timestamp: %s' %(row[0],row[1]))
141  insertedSince = row[0]
142  elif expectedAction == 'SYNCHRONIZE':
143  if destSince == row[0]:
144  self.log( 'ERROR: the since inserted %s has not been synchronized with the FCSR - expected action: %s' %(row[0],expectedAction))
145  self.errors += 1
146  else:
147  self.log( '# OK: Found synchronized value for the last since inserted: %s timestamp: %s' %(row[0],row[1]))
148  insertedSince = row[0]
149  else:
150  self.log( 'ERROR: found an appended since %s - expected action: %s' %(row[0],expectedAction))
151  self.errors += 1
152  else:
153  if not row is None:
154  self.log( 'ERROR: found new insered since: %s timestamp: %s' %(row[0],row[1]))
155  self.errors += 1
156  if expectedAction != 'FAIL':
157  self.log( 'ERROR: Upload failed. Expected value: %s' %(destSince))
158  self.errors += 1
159  else:
160  self.log( '# OK: Upload failed as expected.')
161  os.remove( destFile )
162  os.remove( metaDestFile )
163  return insertedSince
164 

Member Data Documentation

conditionUploadTest.UploadTest.db

Definition at line 106 of file conditionUploadTest.py.

conditionUploadTest.UploadTest.errors

Definition at line 107 of file conditionUploadTest.py.

Referenced by conditionUploadTest.UploadTest.upload().

conditionUploadTest.UploadTest.logFileName

Definition at line 108 of file conditionUploadTest.py.

Referenced by conditionUploadTest.UploadTest.log(), and conditionUploadTest.UploadTest.upload().