|
31 | 31 | ) |
32 | 32 |
|
33 | 33 |
|
34 | | -# def test_attach_initial(mock_get_external_ip): |
35 | | -# # Create a mock AxonServer instance |
36 | | -# server = Axon() |
37 | | -# |
38 | | -# # Define the Synapse type |
39 | | -# class TestSynapse(Synapse): |
40 | | -# pass |
41 | | -# |
42 | | -# # Define the functions with the correct signatures |
43 | | -# def forward_fn(synapse: TestSynapse) -> Any: |
44 | | -# pass |
45 | | -# |
46 | | -# def blacklist_fn(synapse: TestSynapse) -> Tuple[bool, str]: |
47 | | -# return True, "" |
48 | | -# |
49 | | -# def priority_fn(synapse: TestSynapse) -> float: |
50 | | -# return 1.0 |
51 | | -# |
52 | | -# def verify_fn(synapse: TestSynapse) -> None: |
53 | | -# pass |
54 | | -# |
55 | | -# # Test attaching with correct signatures |
56 | | -# server.attach(forward_fn, blacklist_fn, priority_fn, verify_fn) |
57 | | -# |
58 | | -# # Define functions with incorrect signatures |
59 | | -# def wrong_blacklist_fn(synapse: TestSynapse) -> int: |
60 | | -# return 1 |
61 | | -# |
62 | | -# def wrong_priority_fn(synapse: TestSynapse) -> int: |
63 | | -# return 1 |
64 | | -# |
65 | | -# def wrong_verify_fn(synapse: TestSynapse) -> bool: |
66 | | -# return True |
67 | | -# |
68 | | -# # Test attaching with incorrect signatures |
69 | | -# with pytest.raises(AssertionError): |
70 | | -# server.attach(forward_fn, wrong_blacklist_fn, priority_fn, verify_fn) |
71 | | -# |
72 | | -# with pytest.raises(AssertionError): |
73 | | -# server.attach(forward_fn, blacklist_fn, wrong_priority_fn, verify_fn) |
74 | | -# |
75 | | -# with pytest.raises(AssertionError): |
76 | | -# server.attach(forward_fn, blacklist_fn, priority_fn, wrong_verify_fn) |
77 | | -# |
| 34 | +def test_attach_initial(mock_get_external_ip): |
| 35 | + # Create a mock AxonServer instance |
| 36 | + server = Axon() |
| 37 | + |
| 38 | + # Define the Synapse type |
| 39 | + class TestSynapse(Synapse): |
| 40 | + pass |
| 41 | + |
| 42 | + # Define the functions with the correct signatures |
| 43 | + def forward_fn(synapse: TestSynapse) -> Any: |
| 44 | + pass |
| 45 | + |
| 46 | + def blacklist_fn(synapse: TestSynapse) -> Tuple[bool, str]: |
| 47 | + return True, "" |
| 48 | + |
| 49 | + def priority_fn(synapse: TestSynapse) -> float: |
| 50 | + return 1.0 |
| 51 | + |
| 52 | + def verify_fn(synapse: TestSynapse) -> None: |
| 53 | + pass |
| 54 | + |
| 55 | + # Test attaching with correct signatures |
| 56 | + server.attach(forward_fn, blacklist_fn, priority_fn, verify_fn) |
| 57 | + |
| 58 | + # Define functions with incorrect signatures |
| 59 | + def wrong_blacklist_fn(synapse: TestSynapse) -> int: |
| 60 | + return 1 |
| 61 | + |
| 62 | + def wrong_priority_fn(synapse: TestSynapse) -> int: |
| 63 | + return 1 |
| 64 | + |
| 65 | + def wrong_verify_fn(synapse: TestSynapse) -> bool: |
| 66 | + return True |
| 67 | + |
| 68 | + # Test attaching with incorrect signatures |
| 69 | + with pytest.raises(AssertionError): |
| 70 | + server.attach(forward_fn, wrong_blacklist_fn, priority_fn, verify_fn) |
| 71 | + |
| 72 | + with pytest.raises(AssertionError): |
| 73 | + server.attach(forward_fn, blacklist_fn, wrong_priority_fn, verify_fn) |
| 74 | + |
| 75 | + with pytest.raises(AssertionError): |
| 76 | + server.attach(forward_fn, blacklist_fn, priority_fn, wrong_verify_fn) |
| 77 | + |
78 | 78 |
|
79 | 79 | def test_attach(mock_get_external_ip): |
80 | 80 | # Create a mock AxonServer instance |
|
0 commit comments