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