Ejemplo n.º 1
0
 def testCmp(self):
     tags = [ Tag(name='Timing'), Tag(name='Magnets') ]
     logbooks = [ Logbook(name='experiment', owner='controls') ]
     logEntry1 = LogEntry(text='Turning on LINAC', owner='controls', logbooks=logbooks, tags=tags, id=1234)
     logEntry2 = LogEntry(text='Turning on LINAC', owner='controls', logbooks=logbooks, tags=tags, id=1234)
     self.assertEqual(logEntry1, logEntry2, 'Failed LogEntry equality')
     self.assertIn(logEntry1, [logEntry2])
Ejemplo n.º 2
0
 def testCreateTag(self):
     '''
     A Tag consists of a name and a state
     '''        
     tag1 = Tag(name='tagName')
     self.assertEqual(tag1.getName(), 'tagName', 'failed to create the tag correctly')
     '''Check equality which is based on name and state'''
     taga = Tag(name='testName', state='Active')
     tagb = Tag(name='testName', state='Active')
     self.assertEqual(taga, tagb, 'Failed equality condition')
     self.assertEqual([taga], [tagb], 'Failed equality condition')
     pass
Ejemplo n.º 3
0
    def testCreateLog(self):
        '''
        '''
        tags = [ Tag(name='Timing'), Tag(name='Magnets') ]
        logbooks = [ Logbook(name='experiment', owner='controls') ]
        logEntry = LogEntry(text='Turning on LINAC', owner='controls', logbooks=logbooks, tags=tags)
        self.assertEqual(logEntry.getText(), 'Turning on LINAC', 'msg')
        self.assertEqual(logEntry.getOwner(), 'controls', 'msg')
        self.assertEqual(logEntry.getTags(), tags, 'msg')
#        self.assertTrue(logEntry.hasTag('Timing'), 'msg')
        self.assertEqual(logEntry.getLogbooks(), logbooks, 'msg')
#        self.assertTrue(logEntry.hasLogbook('experiment'), 'msg')
        pass
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def testCreateTag(self):
     '''
     Basic operations of creating, listing and deleting a Tag object
     '''
     client = OlogClient(url=getDefaultTestConfig('url'), username=getDefaultTestConfig('username'), password=getDefaultTestConfig('password'))
     testTag = Tag(name='testTag', state="Active")
     client.createTag(testTag)
     self.assertTrue(testTag in client.listTags(), 'failed to create the testTag')
     client.delete(tagName='testTag')
     self.assertTrue(testTag not in client.listTags(), 'failed to cleanup the testTag')
Ejemplo n.º 6
0
 def testCreateEntryWithTag(self):
     client = OlogClient(url=getDefaultTestConfig('url'), username=getDefaultTestConfig('username'), password=getDefaultTestConfig('password'))
     testLogbook = Logbook(name='testLogbook', owner='testOwner')
     client.createLogbook(testLogbook);
     testTag = Tag(name='testTag')
     client.createTag(testTag)        
     text = 'test python log entry with tag ' + datetime.now().isoformat(' ')
     testLog = LogEntry(text=text,
                        owner='testOwner',
                        logbooks=[testLogbook],
                        tags=[testTag])
     client.log(testLog)
     logEntries = client.find(search=testLog.getText())
     self.assertTrue(len(logEntries) == 1, 'Failed to create log Entry with Tag')
     self.assertTrue(testTag in logEntries[0].getTags(), 'testTag not attached to the testLogEntry1')
     '''cleanup'''
     client.delete(logEntryId=logEntries[0].getId())
     self.assertTrue(len(client.find(search=testLog.getText())) == 0, 'Failed to delete log Entry with Tag')
     client.delete(logbookName=testLogbook.getName())
     self.assertTrue(testLogbook not in client.listLogbooks(), 'failed to cleanup the testLogbook')
     client.delete(tagName=testTag.getName())
     self.assertTrue(testTag not in client.listTags(), 'failed to cleanup the testTag')
     pass