def __init__(self, command, timestamp_before, response=None, timestamp_after=None): self.command = command # Command self.timestamp_before = timestamp_before # seconds.millis since 1970 in GMT if response == None: self.response = Command.NullCommand() else: self.response = response self.timestamp_after = timestamp_after
def __init__(self, file_path, file_hash, timestamp_before, response=None, timestamp_after=None, file_info=None): self.file_path = file_path self.file_hash = file_hash self.file_info = file_info self.timestamp_before = timestamp_before if response == None: self.response = Command.NullCommand() else: self.response = response self.timestamp_after = timestamp_after
def test_update_command(self): student1 = self.gateway._get_user(self.session, 'student1') RESERVATION_ID1 = 'my_reservation_id1' usage1 = ExperimentUsage() usage1.start_date = time.time() usage1.end_date = time.time() usage1.from_ip = "130.206.138.16" usage1.experiment_id = ExperimentId("ud-dummy", "Dummy experiments") usage1.coord_address = CoordAddress("machine1", "instance1", "server1") usage1.reservation_id = RESERVATION_ID1 usage1.request_info = { 'facebook': False, 'permission_scope': 'user', 'permission_id': student1.id } self.gateway.store_experiment_usage(student1.login, usage1) usages = self.gateway.list_usages_per_user(student1.login) self.assertEquals(1, len(usages)) full_usage = self.gateway.retrieve_usage(usages[0].experiment_use_id) self.assertEquals(0, len(full_usage.commands)) command1 = CommandSent(Command.Command("your command"), time.time()) command_id = self.gateway.append_command(RESERVATION_ID1, command1) full_usage = self.gateway.retrieve_usage(usages[0].experiment_use_id) self.assertEquals("your command", full_usage.commands[0].command.commandstring) self.assertEquals(Command.NullCommand(), full_usage.commands[0].response) self.gateway.update_command(command_id, Command.Command("the response"), time.time()) full_usage = self.gateway.retrieve_usage(usages[0].experiment_use_id) self.assertEquals("your command", full_usage.commands[0].command.commandstring) self.assertEquals("the response", full_usage.commands[0].response.commandstring)