예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
 def test_init():
     assert ReferencesDict({"a": 10})
예제 #5
0
 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"]
예제 #6
0
 def test_repr():
     assert repr(ReferencesDict({"a": 10}))
예제 #7
0
 def test_str():
     assert str(ReferencesDict({"a": 10}))
예제 #8
0
 def test_len():
     assert len(ReferencesDict({"a": 10})) == 1
예제 #9
0
 def test_RefValue_call():
     refs_dict = ReferencesDict({"a": 10})
     ref_val = ReferencesDict.RefValue(refs_dict, "a")
     assert ref_val() == 10
예제 #10
0
 def test_del():
     refs_dict = ReferencesDict({"a": 10})
     del refs_dict["a"]
     assert "a" not in refs_dict
예제 #11
0
 def test_get_ref_missing():
     with pytest.raises(KeyError):
         refs_dict = ReferencesDict()
         refs_dict2 = ReferencesDict({"a": refs_dict.ref_to("a")})
         refs_dict2["a"]
예제 #12
0
 def test_get_missing():
     with pytest.raises(KeyError):
         refs_dict = ReferencesDict()
         refs_dict["a"]
예제 #13
0
 def test_get_ref():
     refs_dict = ReferencesDict({"a": 10})
     refs_dict2 = ReferencesDict({"b": refs_dict.ref_to("a")})
     assert refs_dict2["b"] == 10
예제 #14
0
 def test_get():
     refs_dict = ReferencesDict({"a": 10})
     assert refs_dict["a"] == 10
예제 #15
0
 def test_ref_to_before():
     refs_dict = ReferencesDict()
     assert refs_dict.ref_to("a")
예제 #16
0
 def test_ref_to():
     refs_dict = ReferencesDict({"a": 10})
     assert refs_dict.ref_to("a")
예제 #17
0
 def test_iter():
     assert next(iter(ReferencesDict({"a": 10}))) == "a"
예제 #18
0
 def test_RefValue_init():
     refs_dict = ReferencesDict()
     assert ReferencesDict.RefValue(refs_dict, "a")