def test_assigns_generation_correctly_when_addition_non_agent_included(self, net): nodes.RandomBinaryStringSource(network=net) net.max_size += 1 # Necessary hack if you want to add another Node. nodes.Environment(network=net) by_gen = self._fill(net) for generation in by_gen.values(): assert len(generation) == net.generation_size
def test_environment_update(self, db_session): net = models.Network() db_session.add(net) environment = nodes.Environment(network=net) environment.update("some content") db_session.commit() state = environment.state() assert state.contents == u"some content"
def test_create_environment(self): """Create an environment""" net = models.Network() self.db.add(net) environment = nodes.Environment(network=net) information.State(origin=environment, contents="foo") self.db.commit() assert isinstance(environment.id, int) assert environment.type == "environment" assert environment.creation_time assert environment.state().contents == "foo"
def test_create_environment_get_observed(self, db_session): net = models.Network() db_session.add(net) environment = nodes.Environment(network=net) information.State(origin=environment, contents="foo") agent = nodes.ReplicatorAgent(network=net) environment.connect(direction="to", whom=agent) environment.transmit(to_whom=agent) agent.receive() assert agent.infos()[0].contents == "foo"