Skip to content

Commit aaad59a

Browse files
committed
[tests] Fixed broken tests
1 parent d317b21 commit aaad59a

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

openwisp_monitoring/check/tests/test_models.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def test_auto_check_creation(self):
145145
def test_device_deleted(self):
146146
self.assertEqual(Check.objects.count(), 0)
147147
d = self._create_device(organization=self._create_org())
148-
self.assertEqual(Check.objects.count(), 2)
148+
self.assertEqual(Check.objects.count(), 3)
149149
d.delete()
150150
self.assertEqual(Check.objects.count(), 0)
151151

@@ -156,7 +156,7 @@ def test_config_modified_device_problem(self):
156156
self._create_config(status='modified', organization=self._create_org())
157157
d = Device.objects.first()
158158
d.monitoring.update_status('ok')
159-
self.assertEqual(Check.objects.count(), 2)
159+
self.assertEqual(Check.objects.count(), 3)
160160
self.assertEqual(Metric.objects.count(), 0)
161161
self.assertEqual(AlertSettings.objects.count(), 0)
162162
check = Check.objects.filter(check_type=self._CONFIG_APPLIED).first()
@@ -186,7 +186,7 @@ def test_config_error(self):
186186
self._create_config(status='error', organization=self._create_org())
187187
dm = Device.objects.first().monitoring
188188
dm.update_status('ok')
189-
self.assertEqual(Check.objects.count(), 2)
189+
self.assertEqual(Check.objects.count(), 3)
190190
self.assertEqual(Metric.objects.count(), 0)
191191
self.assertEqual(AlertSettings.objects.count(), 0)
192192
check = Check.objects.filter(check_type=self._CONFIG_APPLIED).first()
@@ -219,7 +219,7 @@ def test_config_error(self):
219219
@patch('openwisp_monitoring.check.settings.AUTO_PING', False)
220220
def test_config_check_critical_metric(self):
221221
self._create_config(status='modified', organization=self._create_org())
222-
self.assertEqual(Check.objects.count(), 2)
222+
self.assertEqual(Check.objects.count(), 3)
223223
d = Device.objects.first()
224224
dm = d.monitoring
225225
dm.update_status('ok')
@@ -238,7 +238,7 @@ def test_config_check_critical_metric(self):
238238

239239
def test_no_duplicate_check_created(self):
240240
self._create_config(organization=self._create_org())
241-
self.assertEqual(Check.objects.count(), 2)
241+
self.assertEqual(Check.objects.count(), 3)
242242
d = Device.objects.first()
243243
auto_create_config_check.delay(
244244
model=Device.__name__.lower(),
@@ -261,7 +261,7 @@ def test_device_unreachable_no_config_check(self):
261261
self._create_config(status='modified', organization=self._create_org())
262262
d = self.device_model.objects.first()
263263
d.monitoring.update_status('critical')
264-
self.assertEqual(Check.objects.count(), 2)
264+
self.assertEqual(Check.objects.count(), 3)
265265
c2 = Check.objects.filter(check_type=self._CONFIG_APPLIED).first()
266266
c2.perform_check()
267267
self.assertEqual(Metric.objects.count(), 0)
@@ -272,7 +272,7 @@ def test_device_unknown_no_config_check(self):
272272
self._create_config(status='modified', organization=self._create_org())
273273
d = self.device_model.objects.first()
274274
d.monitoring.update_status('unknown')
275-
self.assertEqual(Check.objects.count(), 2)
275+
self.assertEqual(Check.objects.count(), 3)
276276
c2 = Check.objects.filter(check_type=self._CONFIG_APPLIED).first()
277277
c2.perform_check()
278278
self.assertEqual(Metric.objects.count(), 0)

openwisp_monitoring/check/tests/test_ping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def test_store_result(self, mocked_method):
239239
device.management_ip = '10.40.0.1'
240240
device.save()
241241
# check created automatically by autoping
242-
self.assertEqual(Check.objects.count(), 2)
242+
self.assertEqual(Check.objects.count(), 3)
243243
self.assertEqual(Metric.objects.count(), 0)
244244
self.assertEqual(Chart.objects.count(), 0)
245245
self.assertEqual(AlertSettings.objects.count(), 0)

openwisp_monitoring/device/tests/test_transactions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def test_trigger_device_recovery_task_regression(
6262
dm = self._create_device_monitoring()
6363
dm.device.management_ip = None
6464
dm.device.save()
65+
# Delete snmp check to prevent unnecessary response timeout
66+
Check.objects.filter(check_type__endswith='Snmp').delete()
6567
trigger_device_checks.delay(dm.device.pk)
6668
self.assertTrue(Check.objects.exists())
6769
# we expect update_status() to be called once (by the check)

openwisp_monitoring/tests/test_selenium.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def test_restoring_deleted_device(self):
8282
org = self._get_org()
8383
self._create_credentials(auto_add=True, organization=org)
8484
device = self._create_config(organization=org).device
85+
# Delete snmp check to prevent unnecessary response timeout
86+
Check.objects.filter(check_type__endswith='Snmp').delete()
8587
device_data = DeviceData.objects.get(id=device.id)
8688
device_checks = device_data.checks.all()
8789
for check in device_checks:

0 commit comments

Comments
 (0)