End-of-day commit

This commit is contained in:
Marek Wolan
2023-09-25 16:04:04 +01:00
parent 53fd4ed828
commit 9d4e41435d
7 changed files with 722 additions and 80 deletions

View File

@@ -0,0 +1,20 @@
from gym import spaces
from primaite.game.actor.observations import FileObservation
from primaite.simulator.network.hardware.nodes.computer import Computer
from primaite.simulator.sim_container import Simulation
def test_file_observation():
sim = Simulation()
pc = Computer(hostname="beep", ip_address="123.123.123.123", subnet_mask="255.255.255.0")
sim.network.add_node(pc)
f = pc.file_system.create_file(file_name="dog.png")
state = sim.describe_state()
dog_file_obs = FileObservation(
where=["network", "nodes", pc.uuid, "file_system", "folders", "root", "files", "dog.png"]
)
assert dog_file_obs(state) == {"health_status": 1}
assert dog_file_obs.space == spaces.Dict({"health_status": spaces.Discrete(6)})