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
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