Exemplo n.º 1
0
 def setUpClass(cls):
     cls.client = client = OlogClient(url=getDefaultTestConfig('url'), username=getDefaultTestConfig('username'), password=getDefaultTestConfig('password'))
     cls.text = 'test python log entry with attachment ' + datetime.now().isoformat(' ')
     cls.testAttachment = Attachment(open('debug.log', 'rb'))
     cls.testLogbook = Logbook(name='testLogbook', owner='testOwner')
     cls.client.createLogbook(cls.testLogbook);
     cls.testTag = Tag(name='testTag') 
     cls.client.createTag(cls.testTag)               
     cls.testProperty = Property(name='testLogProperty', attributes={'id':'testSearchId', 'url':'www.bnl.gov'})
     cls.client.createProperty(cls.testProperty)
     cls.t1 = str(time.time()).split('.')[0]
     client.log(LogEntry(text=cls.text,
                        owner='testOwner',
                        logbooks=[cls.testLogbook],
                        tags=[cls.testTag],
                        attachments=[cls.testAttachment],
                        properties=[cls.testProperty]))
     cls.t2 = str(time.time()).split('.')[0]
     client.log(LogEntry(text=cls.text + ' - entry2',
                        owner='testOwner',
                        logbooks=[cls.testLogbook]))
     cls.t3 = str(time.time()).split('.')[0]
     cls.testLogEntry1 = client.find(search=cls.text)[0]
     cls.testLogEntry2 = client.find(search=cls.text + ' - entry2')[0]
     pass
Exemplo n.º 2
0
 def CreateProperty(self):
     '''
     Basic operations of creating, listing and deleting a property object
     TODO: the cleanup needs to be resolved
     '''
     client = OlogClient(url=getDefaultTestConfig('url'), username=getDefaultTestConfig('username'), password=getDefaultTestConfig('password'))
     testAttributes = {"attr":"test"}
     testProperty = Property(name='testProperty31', attributes=testAttributes)
     client.createProperty(testProperty)
     self.assertTrue(testProperty in client.listProperties(), 'failed to create the testProperty')
     '''Delete Property only deletes attributes in the service - will be fixed in the service'''
     client.delete(propertyName='testProperty31')
     self.assertTrue(testProperty not in client.listProperties(), 'failed to cleanup the testProperty')
Exemplo n.º 3
0
 def testCreateProperty(self):
     '''
     A Property consists of a name(required) and a set of attributes
     '''      
     attributes = {'attribute1':'attribute1Value', 'attribute2':'attribute2Value'}
     property1 = Property('propertyName', attributes=attributes)
     self.assertEqual(property1.getName(), 'propertyName', '')
     self.assertEqual(property1.getAttributes(), attributes , '')
     self.assertEqual(set(property1.getAttributeNames()), set(['attribute1', 'attribute2']), '')
     self.assertEqual(property1.getAttributeValue('attribute1'), 'attribute1Value', '')
     property2 = Property(name='propertyName', attributes={'attribute1':'attribute1Value', 'attribute2':'attribute2Value'})
     self.assertEqual(property1, property2, 'Failed equality condition')
     pass
Exemplo n.º 4
0
 def testProcess(self):
     client = OlogClient(url=getDefaultTestConfig('url'), username=getDefaultTestConfig('username'), password=getDefaultTestConfig('password'))
     property = Property(name='Process',
                         attributes={'processType':'diffCalc',
                                     'processId':'1234',
                                     'processAttchments':'debug.log'})
     client.createProperty(property)
     # load Data
     client.log(LogEntry(text='Initial setup',
                        owner='experimenter',
                        logbooks=[self.testLogbook],
                        properties=[property],
                        attachments=[Attachment(open('debug.log', 'rb'))]
                        ))
     # run scan
     property = Property(name='Process',
                         attributes={'processType':'diffCalc.process',
                                     'processId':'1234',
                                     'processAttchments':'.log'})
     client.log(LogEntry(text='Initial setup',
                        owner='experimenter',
                        logbooks=[self.testLogbook],
                        properties=[property]
                        ))
Exemplo n.º 5
0
    def testCreateEntryWithProperties(self):
        client = OlogClient(url=getDefaultTestConfig('url'), username=getDefaultTestConfig('username'), password=getDefaultTestConfig('password'))
        testLogbook = Logbook(name='testLogbook', owner='testOwner')
        client.createLogbook(testLogbook);
        testProperty = Property(name='testLogProperty', attributes={'id':None, 'url':None})
#        client.createProperty(testProperty)
        text = 'test python log entry with attachment ' + datetime.now().isoformat(' ')
        property = Property(name='testLogProperty', attributes={'id':'prop1234', 'url':'www.bnl.gov'})
        testLog = LogEntry(text=text,
                           owner='testOwner',
                           logbooks=[testLogbook],
                           properties=[property]
                           )
        client.log(testLog)
        logEntries = client.find(search=text)
        self.assertEqual(len(logEntries), 1, 'Failed to create log entry with property')
        properties = logEntries[0].getProperties()
        self.assertIn(property, properties, 'TestLogEntry does not contain property ' + property.getName())
        '''Cleanup'''
        client.delete(logEntryId=logEntries[0].getId()) 
        self.assertEqual(len(client.find(search=text)), 0, 'Failed to cleanup log entry with property') 
        client.delete(logbookName=testLogbook.getName())
        self.assertTrue(testLogbook not in client.listLogbooks(), 'failed to cleanup the ' + testLogbook.getName())
        pass