def process(self, currentTimeStep, currentTopics, currentUsers, **conf): if not currentTopics: Topic.addNewTopics(currentTopics, conf.get('noOfTopics', 5000)) random.shuffle(currentUsers) for user in currentUsers: message = self.messageSelectionMethod(currentTimeStep, user, currentTopics, **conf) if message: topic = message.topic topic.countDistribution[currentTimeStep]+=1 topic.totalCount+=1 self.topicToMessagesMap[topic.id].append(message) self.totalMessages+=1 if message.payLoad.isSpam: self.messagesWithSpamPayload+=1 self.topicsDistributionInTheTimeSet[topic.id]+=1
def test_generate(self): topics = [] Topic.addNewTopics(topics, 2) Topic.addNewTopics(topics, 5) self.assertEqual(7, len(topics)) for i in range(7): self.assertEqual(i, topics[i].id)