Skip to content

Commit

Permalink
AIDT-67: remove partial configs and use base test config + code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
czar-ec-envitia committed Nov 8, 2022
1 parent d79b025 commit 0155712
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 304 deletions.
4 changes: 4 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
TEST_CONFIG_PATH: Final[Path] = Path(
os.path.join(Path(__file__).parent.resolve(), "test_configs")
)

TEST_BASE_CONFIG_PATH = Path(
os.path.join(Path(__file__).parent.resolve(), "test_configs", "base_config.yaml")
)
File renamed without changes.
90 changes: 0 additions & 90 deletions tests/test_configs/config_sections/complete_blue_agent_config.yaml

This file was deleted.

31 changes: 0 additions & 31 deletions tests/test_configs/config_sections/complete_game_rules_config.yaml

This file was deleted.

This file was deleted.

64 changes: 0 additions & 64 deletions tests/test_configs/config_sections/complete_red_agent_config.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions tests/test_configs/config_sections/complete_reset_config.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions tests/test_configs/config_sections/complete_rewards_config.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions tests/unit_tests/config/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
import os
from pathlib import Path
from typing import Final

from tests import TEST_CONFIG_PATH

TEST_BLUE_AGENT_CONFIG_PATH: Final[Path] = Path(
os.path.join(TEST_CONFIG_PATH, "config_sections", "complete_blue_agent_config.yaml")
)

TEST_RED_AGENT_CONFIG_PATH: Final[Path] = Path(
os.path.join(TEST_CONFIG_PATH, "config_sections", "complete_red_agent_config.yaml")
)
29 changes: 14 additions & 15 deletions tests/unit_tests/config/agents/test_blue_agent_config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import os
from typing import Dict, Any

import pytest

from tests.unit_tests.config.agents import TEST_BLUE_AGENT_CONFIG_PATH
from tests.unit_tests.config.config_test_utils import read_yaml_file
from tests import TEST_BASE_CONFIG_PATH
from tests.config_test_utils import read_yaml_file
from yawning_titan.config.agents.blue_agent_config import BlueAgentConfig


def get_config_dict() -> Dict:
return read_yaml_file(TEST_BLUE_AGENT_CONFIG_PATH)
return read_yaml_file(TEST_BASE_CONFIG_PATH)["BLUE"]


def test_read_valid_config():
Expand All @@ -19,10 +18,10 @@ def test_read_valid_config():
assert blue_agent.blue_max_deceptive_nodes == 2

# chance_to_immediately_discover_intrusion
assert blue_agent.blue_immediate_detection_chance
assert blue_agent.blue_immediate_detection_chance == 0.5

# chance_to_discover_intrusion_on_scan
assert blue_agent.blue_scan_detection_chance == 1
assert blue_agent.blue_scan_detection_chance == 0.7

# chance_to_immediately_discover_intrusion_deceptive_node
assert blue_agent.blue_deception_immediate_detection_chance == 1
Expand All @@ -40,13 +39,13 @@ def test_read_valid_config():
assert blue_agent.blue_discover_attack_source_if_not_detected is True

# chance_to_discover_failed_attack
assert blue_agent.blue_chance_to_discover_source_failed == 1
assert blue_agent.blue_chance_to_discover_source_failed == 0.5

# chance_to_discover_succeeded_attack_compromise_known
assert blue_agent.blue_chance_to_discover_source_succeed_known == 1
assert blue_agent.blue_chance_to_discover_source_succeed_known == 0.3

# chance_to_discover_succeeded_attack_compromise_not_known
assert blue_agent.blue_chance_to_discover_source_succeed_unknown == 1
assert blue_agent.blue_chance_to_discover_source_succeed_unknown == 0.1

# chance_to_discover_failed_attack_deceptive_node
assert blue_agent.blue_chance_to_discover_source_deceptive_failed == 1
Expand All @@ -61,10 +60,10 @@ def test_read_valid_config():
assert blue_agent.blue_vuln_change_amount_make_safe == 0.4

# making_node_safe_gives_random_vulnerability
assert blue_agent.blue_make_safe_random_vuln is False
assert blue_agent.blue_make_safe_random_vuln is True

# blue_uses_reduce_vulnerability
assert blue_agent.blue_reduce_vuln_action is False
assert blue_agent.blue_reduce_vuln_action is True

# blue_uses_restore_node
assert blue_agent.blue_restore_node_action is True
Expand All @@ -76,16 +75,16 @@ def test_read_valid_config():
assert blue_agent.blue_scan_action is True

# blue_uses_isolate_node
assert blue_agent.blue_isolate_action is False
assert blue_agent.blue_isolate_action is True

# blue_uses_reconnect_node
assert blue_agent.blue_reconnect_action is False
assert blue_agent.blue_reconnect_action is True

# blue_uses_do_nothing is False
assert blue_agent.blue_do_nothing_action is False
assert blue_agent.blue_do_nothing_action is True

# blue_uses_deceptive_nodes
assert blue_agent.blue_deceptive_action is False
assert blue_agent.blue_deceptive_action is True

# relocating_deceptive_nodes_generates_a_new_node
assert blue_agent.blue_deceptive_node_make_new is True
Expand Down
18 changes: 9 additions & 9 deletions tests/unit_tests/config/agents/test_red_agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import pytest

from tests.unit_tests.config.agents import TEST_RED_AGENT_CONFIG_PATH
from tests.unit_tests.config.config_test_utils import read_yaml_file
from tests import TEST_BASE_CONFIG_PATH
from tests.config_test_utils import read_yaml_file
from yawning_titan.config.agents.red_agent_config import RedAgentConfig


def get_config_dict() -> Dict:
return read_yaml_file(TEST_RED_AGENT_CONFIG_PATH)
return read_yaml_file(TEST_BASE_CONFIG_PATH)["RED"]


def test_read_valid_config():
Expand Down Expand Up @@ -36,10 +36,10 @@ def test_read_valid_config():
assert red_agent.red_naturally_spread is True

# chance_to_spread_to_connected_node
assert red_agent.red_chance_to_spread_to_connected_node == 0.05
assert red_agent.red_chance_to_spread_to_connected_node == 0.01

# chance_to_spread_to_unconnected_node
assert red_agent.red_chance_to_spread_to_unconnected_node == 0
assert red_agent.red_chance_to_spread_to_unconnected_node == 0.005

# red_uses_spread_action
assert red_agent.red_spread_action is False
Expand All @@ -63,7 +63,7 @@ def test_read_valid_config():
assert red_agent.red_basic_attack_action is True

# basic_attack_action_likelihood
assert red_agent.red_basic_attack_likelihood == 2
assert red_agent.red_basic_attack_likelihood == 1

# red_uses_do_nothing_action
assert red_agent.red_do_nothing_action is True
Expand All @@ -84,13 +84,13 @@ def test_read_valid_config():
assert red_agent.red_zero_day_start_amount == 1

# days_required_for_zero_day
assert red_agent.red_zero_day_days_required_to_create == 4
assert red_agent.red_zero_day_days_required_to_create == 10

# red_chooses_target_at_random
assert red_agent.red_targeting_random is True
assert red_agent.red_targeting_random is False

# red_prioritises_connected_nodes
assert red_agent.red_targeting_prioritise_connected_nodes is False
assert red_agent.red_targeting_prioritise_connected_nodes is True

# red_prioritises_un_connected_nodes
assert red_agent.red_targeting_prioritise_unconnected_nodes is False
Expand Down
Loading

0 comments on commit 0155712

Please sign in to comment.