Commit aec6937
🧪 test: add tests for parse_site_location edge cases (#38)
* test: add tests for parse_site_location edge cases
Added unit tests to `tests/unit/test_cli/test_http/test_api/test_site_location.py` to cover `parse_site_location`. The tests cover standard string format, string containing spaces, exceptions handling incorrect lengths (too few or too many parameters), incorrect coordinate formats (non-float characters), and empty strings.
Co-authored-by: rnovatorov <[email protected]>
* test: fix flaky mqtt adapter tests with events
The `test_standalone/test_mqtt_adapter.py` test suite used `await asyncio.sleep(0.02)` to wait for mocked methods to be called before assertions. Under higher load, or in some configurations like Python 3.13, this constant delay was insufficient, causing intermittent failures such as `AssertionError: Expected 'publish_log' to have been called`. This replaces the arbitrary sleeps with deterministic synchronization primitives (`asyncio.Event`) where tests wait explicitly for up to 1 second for the mocked function to be called before checking assertions.
Co-authored-by: rnovatorov <[email protected]>
* test: fix flaky mqtt adapter tests with events
The `test_standalone/test_mqtt_adapter.py` test suite used `await asyncio.sleep(0.02)` to wait for mocked methods to be called before assertions. Under higher load, or in some configurations like Python 3.13, this constant delay was insufficient, causing intermittent failures such as `AssertionError: Expected 'publish_log' to have been called`. This replaces the arbitrary sleeps with deterministic synchronization primitives (`asyncio.Event`) where tests wait explicitly for up to 1 second for the mocked function to be called before checking assertions.
Also run `black` to format the new code modifications.
Co-authored-by: rnovatorov <[email protected]>
* test: fix flaky mqtt adapter tests using asyncio events
The `tests/unit/test_standalone/test_mqtt_adapter.py` test suite used `await asyncio.sleep(0.02)` to wait for mocked methods to be called before assertions. Under higher load, or in some configurations, this constant delay was insufficient, causing intermittent failures such as `AssertionError: Expected 'publish_log' to have been called`. This replaces the arbitrary sleeps with deterministic synchronization primitives (`asyncio.Event`) where tests wait explicitly for the mocked function to be called before checking assertions.
This commit includes both the code fixes and the `black` formatting applied.
Co-authored-by: rnovatorov <[email protected]>
* fix: strip whitespace from site location name
When parsing site location strings, the `name` is now stripped of extra whitespace to prevent leading and trailing spaces from remaining if passed incorrectly. Updated corresponding unit tests.
Co-authored-by: rnovatorov <[email protected]>
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent 5a4854d commit aec6937
File tree
3 files changed
+92
-10
lines changed- src/enapter/cli/http/api
- tests/unit
- test_cli/test_http/test_api
- test_standalone
3 files changed
+92
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | | - | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| 76 | + | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
80 | 84 | | |
81 | 85 | | |
82 | 86 | | |
83 | | - | |
| 87 | + | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
| |||
94 | 98 | | |
95 | 99 | | |
96 | 100 | | |
| 101 | + | |
| 102 | + | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
| |||
103 | 109 | | |
104 | 110 | | |
105 | 111 | | |
106 | | - | |
| 112 | + | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| |||
119 | 125 | | |
120 | 126 | | |
121 | 127 | | |
122 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
123 | 135 | | |
124 | 136 | | |
125 | 137 | | |
| |||
129 | 141 | | |
130 | 142 | | |
131 | 143 | | |
132 | | - | |
| 144 | + | |
133 | 145 | | |
134 | 146 | | |
135 | 147 | | |
136 | 148 | | |
137 | 149 | | |
138 | 150 | | |
139 | 151 | | |
140 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
141 | 159 | | |
142 | 160 | | |
143 | 161 | | |
| |||
147 | 165 | | |
148 | 166 | | |
149 | 167 | | |
150 | | - | |
| 168 | + | |
151 | 169 | | |
152 | 170 | | |
153 | 171 | | |
154 | 172 | | |
155 | 173 | | |
156 | 174 | | |
157 | 175 | | |
158 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
159 | 183 | | |
160 | 184 | | |
161 | 185 | | |
| |||
165 | 189 | | |
166 | 190 | | |
167 | 191 | | |
168 | | - | |
| 192 | + | |
169 | 193 | | |
170 | 194 | | |
171 | 195 | | |
| |||
0 commit comments