from unittest.mock import Mock

from .context import tohu
from tohu.v3.primitive_generators import *


def test_can_register_clones_which_are_automatically_reset():
    """
    Can register clones and these are automatically reset when the parent is reset
    """
    dummy_clone = Mock()

    g = Integer(100, 200)
    g.register_clone(dummy_clone)

    g.reset(seed=12345)

    dummy_clone.reset.assert_called_once_with(12345)
@@ -1,12 +1,26 @@
+import pytest%0A
 from unittes
@@ -110,16 +110,207 @@
 ort *%0A%0A%0A
+@pytest.mark.parametrize(%22g%22, %5B%0A    Constant(%22quux%22),%0A    Integer(100, 200),%0A    HashDigest(length=6),%0A    FakerGenerator(method=%22name%22),%0A    IterateOver('abcde'),%0A    SelectOne('abcde'),%0A%5D)%0A
 def test
@@ -360,16 +360,17 @@
 y_reset(
+g
 ):%0A    %22
@@ -478,16 +478,18 @@
 my_clone
+_1
  = Mock(
@@ -494,33 +494,69 @@
 k()%0A
-%0A
     
-g = Integer(100, 200
+dummy_clone_2 = Mock()%0A    g.register_clone(dummy_clone_1
 )%0A  
@@ -585,16 +585,18 @@
 my_clone
+_2
 )%0A%0A    g
@@ -614,16 +614,70 @@
 =12345)%0A
+    dummy_clone_1.reset.assert_called_once_with(12345)
 %0A    dum
@@ -684,16 +684,18 @@
 my_clone
+_2
 .reset.a
@@ -703,28 +703,153 @@
 sert_called_once_with(12345)
+%0A%0A    g.reset(seed=99999)%0A    dummy_clone_1.reset.assert_called_with(99999)%0A    dummy_clone_2.reset.assert_called_with(99999)

Test all primitive generators