def test_simulate(monkeypatch): monkeypatch.setattr(InfoStreamer, "send_info", MagicMock()) action = StatefullAction() action._state = ReferencesDict() state = {"a": 10} action.simulate("action", state) assert dict(action.state) == state
def test_simulate(monkeypatch): _enables_rollback_mock = MagicMock() monkeypatch.setattr(UnitAction, "_enables_rollback", _enables_rollback_mock) monkeypatch.setattr(InfoStreamer, "send_info", MagicMock()) action = UnitAction() action._state = ReferencesDict() state = {"a": 10} action.simulate("action", state) assert _enables_rollback_mock.called
def test_3_level(): r1 = ReferencesDict() r2 = ReferencesDict() r3 = ReferencesDict() r1["a"] = 10 r2["a"] = r1.ref_to("a") r3["a"] = r2.ref_to("a") r1["a"] = 20 assert r3["a"] == 20
def test_init(): assert ReferencesDict({"a": 10})
def test_ref_keys(): refs_dict = ReferencesDict({"a": 10}) refs_dict2 = ReferencesDict({"b": 20, "c": refs_dict.ref_to("a")}) assert refs_dict2.ref_keys() == ["c"]
def test_repr(): assert repr(ReferencesDict({"a": 10}))
def test_str(): assert str(ReferencesDict({"a": 10}))
def test_len(): assert len(ReferencesDict({"a": 10})) == 1
def test_RefValue_call(): refs_dict = ReferencesDict({"a": 10}) ref_val = ReferencesDict.RefValue(refs_dict, "a") assert ref_val() == 10
def test_del(): refs_dict = ReferencesDict({"a": 10}) del refs_dict["a"] assert "a" not in refs_dict
def test_get_ref_missing(): with pytest.raises(KeyError): refs_dict = ReferencesDict() refs_dict2 = ReferencesDict({"a": refs_dict.ref_to("a")}) refs_dict2["a"]
def test_get_missing(): with pytest.raises(KeyError): refs_dict = ReferencesDict() refs_dict["a"]
def test_get_ref(): refs_dict = ReferencesDict({"a": 10}) refs_dict2 = ReferencesDict({"b": refs_dict.ref_to("a")}) assert refs_dict2["b"] == 10
def test_get(): refs_dict = ReferencesDict({"a": 10}) assert refs_dict["a"] == 10
def test_ref_to_before(): refs_dict = ReferencesDict() assert refs_dict.ref_to("a")
def test_ref_to(): refs_dict = ReferencesDict({"a": 10}) assert refs_dict.ref_to("a")
def test_iter(): assert next(iter(ReferencesDict({"a": 10}))) == "a"
def test_RefValue_init(): refs_dict = ReferencesDict() assert ReferencesDict.RefValue(refs_dict, "a")