Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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"
Ejemplo n.º 3
0
    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"
Ejemplo n.º 4
0
    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"