def test_stats_single_client_multiple_key(self): a_project = Project('project name') a_client = Client('a_client') listener = ServerListener( client=a_client, project=a_project ) generator = WebGenerator(project_name= a_project.name) listener.current_time = lambda : "2006-04-04-00-00-00" task = Task(a_project, a_client, 'task') task.add_subtask("subtask", [{STATS:lambda x: {'key1':5, 'key2':0} }] ) Runner(task, testinglisteners=[listener]) listener.current_time = lambda : "2006-04-05-00-00-00" task = Task(a_project, a_client, 'task') task.add_subtask("subtask", [{STATS:lambda x: {'key1':-1, 'key2':4} }] ) Runner(task, testinglisteners=[listener]) self.assertEquals( { 'a_client': { 'subtask': [ ('2006-04-04-00-00-00', {'key2': 0, 'key1': 5}), ('2006-04-05-00-00-00', {'key2': 4, 'key1': -1}) ] } }, generator.collect_stats() )
def test_no_stats(self): a_project = Project('project name') a_client = Client('a_client') listener = ServerListener( client=a_client, project=a_project ) generator = WebGenerator(project_name= a_project.name) listener.current_time = lambda : "2006-04-04-00-00-00" task = Task(a_project, a_client, 'task') task.add_subtask("subtask", ["echo no stats"] ) Runner(task, testinglisteners=[listener]) self.assertEquals( {'a_client': {} }, generator.collect_stats() )
def test_stats_multiple_client_single_key(self): a_project = Project('project name') a_client = Client('client1') a_client2 = Client('client2') listener1 = ServerListener( client=a_client, project=a_project ) listener2 = ServerListener( client=a_client2, project=a_project ) generator = WebGenerator(project_name= a_project.name) listener1.current_time = lambda : "2006-04-04-00-00-00" task = Task(a_project, a_client, 'task') task.add_subtask("subtask", [{STATS:lambda x: {'key':5} }] ) Runner(task, testinglisteners=[listener1]) listener1.current_time = lambda : "2006-04-05-00-00-00" task = Task(a_project, a_client, 'task') task.add_subtask("subtask", [{STATS:lambda x: {'key':1} }] ) Runner(task, testinglisteners=[listener1]) listener2.current_time = lambda : "1000-00-00-00-00-00" task = Task(a_project, a_client, 'task') task.add_subtask("subtask", [{STATS:lambda x: {'clau':0} }] ) Runner(task, testinglisteners=[listener2]) self.assertEquals( { 'client1': { 'subtask': [ ('2006-04-04-00-00-00', {'key': 5}), ('2006-04-05-00-00-00', {'key': 1}) ] }, 'client2': {'subtask': [ ('1000-00-00-00-00-00', {'clau': 0}) ] } }, generator.collect_stats() )