'A third configuration change completely replaces a second configuration
change if the first configuration change has not yet been acknowledged.'

def test_third_configuration_change_supercedes_second(self):

    agent = FakeAgent()
    client = AgentAMP(Clock(), agent)
    service_clock = Clock()
    service = build_control_amp_service(self, service_clock)
    service.startService()
    confounding_agent = FakeAgent()
    confounding_client = AgentAMP(Clock(), confounding_agent)
    confounding_server = LoopbackAMPClient(confounding_client.locator)
    service.connected(confounding_server)
    service_clock.advance((CONTROL_SERVICE_BATCHING_DELAY * 2))
    configuration = service.configuration_service.get()
    modified_configuration = arbitrary_transformation(configuration)
    more_modified_configuration = arbitrary_transformation(modified_configuration)
    server = LoopbackAMPClient(client.locator)
    delayed_server = DelayedAMPClient(server)
    service.connected(delayed_server)
    service_clock.advance((CONTROL_SERVICE_BATCHING_DELAY * 2))
    service.configuration_service.save(modified_configuration)
    service_clock.advance((CONTROL_SERVICE_BATCHING_DELAY * 2))
    service.configuration_service.save(more_modified_configuration)
    service_clock.advance((CONTROL_SERVICE_BATCHING_DELAY * 2))
    first_agent_desired = agent.desired
    delayed_server.respond()
    service_clock.advance((CONTROL_SERVICE_BATCHING_DELAY * 2))
    second_agent_desired = agent.desired
    delayed_server.respond()
    third_agent_desired = agent.desired
    self.assertRaises(IndexError, delayed_server.respond)
    self.assertEqual([configuration, more_modified_configuration, more_modified_configuration], [first_agent_desired, second_agent_desired, third_agent_desired])
