def testGetRecentActivityWithEmptyArguments(self): """ L{getRecentActivity} returns an empty generator if no values are provided. """ result = getRecentActivity(objectIDs=[], usernames=[]) self.assertEqual([], list(result))
def testGetRecentActivityWithEmptyArguments(self): """ L{getRecentActivity} returns an empty generator if no values are provided. """ result = getRecentActivity(objectIDs=[], usernames=[]) self.assertEqual([], list(result))
def testGetRecentActivityByUsernameAndObjectID(self): """ L{getRecentActivity} returns the recent tag values for the given objects and usernames. """ objectID1 = self.createDirtyObject(u'object1') objectID2 = self.createDirtyObject(u'object2') objectID3 = self.createDirtyObject(u'object3') time1 = self.makeValue(self.user1, self.user1tag1, objectID1, u'A', 1) time2 = self.makeValue(self.user1, self.user1tag2, objectID1, u'B', 2) time3 = self.makeValue(self.user2, self.user2tag1, objectID2, u'C', 3) time4 = self.makeValue(self.user2, self.user2tag2, objectID2, u'D', 4) self.makeValue(self.user3, self.user3tag1, objectID3, u'E', 5) self.makeValue(self.user3, self.user3tag2, objectID3, u'F', 6) expected = [ (u'user1/tag1', objectID1, u'object1', u'A', u'user1', time1), (u'user1/tag2', objectID1, u'object1', u'B', u'user1', time2), (u'user2/tag1', objectID2, u'object2', u'C', u'user2', time3), (u'user2/tag2', objectID2, u'object2', u'D', u'user2', time4) ] result = getRecentActivity(objectIDs=[objectID1, objectID2], usernames=[u'user1', u'user2']) self.assertEqual(expected, list(result))
def getForObjects(self, objectIDs): """Get information about recent tag values on the given objects. @param objectIDs: A sequence of object IDs to get recent tags from. @return: A C{list} of C{(Tag.path, TagValue.objectID, AboutTagValue.value, TagValue.value, User.username, value.creationTime)} 6-tuples with the information about the recent tag values. """ return self._formatResult(getRecentActivity(objectIDs=objectIDs))
def getForObjects(self, objectIDs): """Get information about recent tag values on the given objects. @param objectIDs: A sequence of object IDs to get recent tags from. @return: A C{list} of C{(Tag.path, TagValue.objectID, AboutTagValue.value, TagValue.value, User.username, value.creationTime)} 6-tuples with the information about the recent tag values. """ return self._formatResult(getRecentActivity(objectIDs=objectIDs))
def testGetRecentActivityByObjectID(self): """ L{getRecentActivity} returns the recent tag values for a given object. """ objectID1 = self.createDirtyObject(u'object1') objectID2 = self.createDirtyObject(u'object2') time1 = self.makeValue(self.user1, self.user1tag1, objectID1, u'A', 1) time2 = self.makeValue(self.user1, self.user1tag2, objectID1, u'B', 2) time3 = self.makeValue(self.user2, self.user2tag2, objectID1, u'D', 4) self.makeValue(self.user2, self.user2tag1, objectID2, u'C', 3) expected = [ (u'user1/tag1', objectID1, u'object1', u'A', u'user1', time1), (u'user1/tag2', objectID1, u'object1', u'B', u'user1', time2), (u'user2/tag2', objectID1, u'object1', u'D', u'user2', time3)] result = getRecentActivity(objectIDs=[objectID1]) self.assertEqual(expected, list(result))
def testGetRecentActivityByObjectIDWithLimit(self): """ L{getRecentActivity} returns only the number of items speficied by the C{limit} argument. """ objectID1 = self.createDirtyObject(u'object1') time1 = self.makeValue(self.user1, self.user1tag1, objectID1, u'A', 1) time2 = self.makeValue(self.user1, self.user1tag2, objectID1, u'B', 2) time3 = self.makeValue(self.user2, self.user2tag1, objectID1, u'C', 3) self.makeValue(self.user2, self.user2tag2, objectID1, u'D', 4) expected = [ (u'user1/tag1', objectID1, u'object1', u'A', u'user1', time1), (u'user1/tag2', objectID1, u'object1', u'B', u'user1', time2), (u'user2/tag1', objectID1, u'object1', u'C', u'user2', time3)] result = getRecentActivity(objectIDs=[objectID1], limit=3) self.assertEqual(expected, list(result))
def testGetRecentActivityByUsernameWithoutAboutValues(self): """ If the requested objects don't have C{fluiddb/about} values, L{getRecentActivity} returns None as L{AboutTagValue}. """ objectID1 = self.createDirtyObject(None) objectID2 = self.createDirtyObject(None) time1 = self.makeValue(self.user1, self.user1tag1, objectID1, u'A', 1) time2 = self.makeValue(self.user1, self.user1tag2, objectID1, u'B', 2) time3 = self.makeValue(self.user1, self.user1tag1, objectID2, u'D', 4) self.makeValue(self.user2, self.user2tag1, objectID1, u'C', 3) expected = [(u'user1/tag1', objectID1, None, u'A', u'user1', time1), (u'user1/tag2', objectID1, None, u'B', u'user1', time2), (u'user1/tag1', objectID2, None, u'D', u'user1', time3)] result = getRecentActivity(usernames=[u'user1']) self.assertEqual(expected, list(result))
def getForUsers(self, usernames): """Get information about recent tag values on the given users. @param usernames: A sequence of usernames to get recent tags from. @raise: L{UnknownUserError} if one of the given usernames doesn't exist. @return: A C{list} of C{(Tag.path, TagValue.objectID, AboutTagValue.value, TagValue.value, User.username, value.creationTime)} 6-tuples with the information about the recent tag values. """ usernames = set(usernames) result = getUsers(usernames=usernames) existingUsernames = set(result.values(User.username)) unknownUsernames = usernames - existingUsernames if unknownUsernames: raise UnknownUserError(list(unknownUsernames)) return self._formatResult(getRecentActivity(usernames=usernames))
def getForUsers(self, usernames): """Get information about recent tag values on the given users. @param usernames: A sequence of usernames to get recent tags from. @raise: L{UnknownUserError} if one of the given usernames doesn't exist. @return: A C{list} of C{(Tag.path, TagValue.objectID, AboutTagValue.value, TagValue.value, User.username, value.creationTime)} 6-tuples with the information about the recent tag values. """ usernames = set(usernames) result = getUsers(usernames=usernames) existingUsernames = set(result.values(User.username)) unknownUsernames = usernames - existingUsernames if unknownUsernames: raise UnknownUserError(list(unknownUsernames)) return self._formatResult(getRecentActivity(usernames=usernames))
def testGetRecentActivityByUsernameWithoutAboutValues(self): """ If the requested objects don't have C{fluiddb/about} values, L{getRecentActivity} returns None as L{AboutTagValue}. """ objectID1 = self.createDirtyObject(None) objectID2 = self.createDirtyObject(None) time1 = self.makeValue(self.user1, self.user1tag1, objectID1, u'A', 1) time2 = self.makeValue(self.user1, self.user1tag2, objectID1, u'B', 2) time3 = self.makeValue(self.user1, self.user1tag1, objectID2, u'D', 4) self.makeValue(self.user2, self.user2tag1, objectID1, u'C', 3) expected = [ (u'user1/tag1', objectID1, None, u'A', u'user1', time1), (u'user1/tag2', objectID1, None, u'B', u'user1', time2), (u'user1/tag1', objectID2, None, u'D', u'user1', time3)] result = getRecentActivity(usernames=[u'user1']) self.assertEqual(expected, list(result))
def testGetRecentActivityByObjectID(self): """ L{getRecentActivity} returns the recent tag values for a given object. """ objectID1 = self.createDirtyObject(u'object1') objectID2 = self.createDirtyObject(u'object2') time1 = self.makeValue(self.user1, self.user1tag1, objectID1, u'A', 1) time2 = self.makeValue(self.user1, self.user1tag2, objectID1, u'B', 2) time3 = self.makeValue(self.user2, self.user2tag2, objectID1, u'D', 4) self.makeValue(self.user2, self.user2tag1, objectID2, u'C', 3) expected = [ (u'user1/tag1', objectID1, u'object1', u'A', u'user1', time1), (u'user1/tag2', objectID1, u'object1', u'B', u'user1', time2), (u'user2/tag2', objectID1, u'object1', u'D', u'user2', time3) ] result = getRecentActivity(objectIDs=[objectID1]) self.assertEqual(expected, list(result))
def testGetRecentActivityByObjectIDWithLimit(self): """ L{getRecentActivity} returns only the number of items speficied by the C{limit} argument. """ objectID1 = self.createDirtyObject(u'object1') time1 = self.makeValue(self.user1, self.user1tag1, objectID1, u'A', 1) time2 = self.makeValue(self.user1, self.user1tag2, objectID1, u'B', 2) time3 = self.makeValue(self.user2, self.user2tag1, objectID1, u'C', 3) self.makeValue(self.user2, self.user2tag2, objectID1, u'D', 4) expected = [ (u'user1/tag1', objectID1, u'object1', u'A', u'user1', time1), (u'user1/tag2', objectID1, u'object1', u'B', u'user1', time2), (u'user2/tag1', objectID1, u'object1', u'C', u'user2', time3) ] result = getRecentActivity(objectIDs=[objectID1], limit=3) self.assertEqual(expected, list(result))
def testGetRecentActivityByUsernameAndObjectID(self): """ L{getRecentActivity} returns the recent tag values for the given objects and usernames. """ objectID1 = self.createDirtyObject(u'object1') objectID2 = self.createDirtyObject(u'object2') objectID3 = self.createDirtyObject(u'object3') time1 = self.makeValue(self.user1, self.user1tag1, objectID1, u'A', 1) time2 = self.makeValue(self.user1, self.user1tag2, objectID1, u'B', 2) time3 = self.makeValue(self.user2, self.user2tag1, objectID2, u'C', 3) time4 = self.makeValue(self.user2, self.user2tag2, objectID2, u'D', 4) self.makeValue(self.user3, self.user3tag1, objectID3, u'E', 5) self.makeValue(self.user3, self.user3tag2, objectID3, u'F', 6) expected = [ (u'user1/tag1', objectID1, u'object1', u'A', u'user1', time1), (u'user1/tag2', objectID1, u'object1', u'B', u'user1', time2), (u'user2/tag1', objectID2, u'object2', u'C', u'user2', time3), (u'user2/tag2', objectID2, u'object2', u'D', u'user2', time4)] result = getRecentActivity(objectIDs=[objectID1, objectID2], usernames=[u'user1', u'user2']) self.assertEqual(expected, list(result))