|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 |
| -import time |
| 15 | +import datetime |
16 | 16 | from unittest.mock import Mock, patch
|
17 | 17 |
|
18 | 18 | import pytest
|
@@ -124,15 +124,27 @@ def test_read_remote_setting(eda_caplog):
|
124 | 124 | },
|
125 | 125 | ]
|
126 | 126 |
|
127 |
| - with patch("aap_eda.analytics.utils.requests.get") as mock_get: |
| 127 | + now = datetime.datetime(2025, 1, 1, 0, 0) |
| 128 | + now_effect = [ |
| 129 | + now, |
| 130 | + now + datetime.timedelta(milliseconds=100), |
| 131 | + now + datetime.timedelta(milliseconds=200), |
| 132 | + now + datetime.timedelta(milliseconds=300), |
| 133 | + now + datetime.timedelta(milliseconds=1400), |
| 134 | + now + datetime.timedelta(milliseconds=1500), |
| 135 | + ] |
| 136 | + |
| 137 | + with ( |
| 138 | + patch("django.utils.timezone.now", side_effect=now_effect), |
| 139 | + patch("aap_eda.analytics.utils.requests.get") as mock_get, |
| 140 | + ): |
128 | 141 | mock_get.return_value = mock_resp
|
129 | 142 | assert application_settings.AUTOMATION_ANALYTICS_GATHER_INTERVAL == 500
|
130 | 143 | assert application_settings.REDHAT_USERNAME == "foo"
|
131 | 144 | # repeat within interval
|
132 | 145 | assert application_settings.AUTOMATION_ANALYTICS_GATHER_INTERVAL == 500
|
133 | 146 | assert application_settings.REDHAT_USERNAME == "foo"
|
134 | 147 |
|
135 |
| - time.sleep(1) |
136 | 148 | # repeat after interval
|
137 | 149 | assert (
|
138 | 150 | application_settings.AUTOMATION_ANALYTICS_GATHER_INTERVAL == 1000
|
|
0 commit comments