[SEBA-367] olt,onu synchronization fix
Change-Id: If7a5709537bda3b634e8aa1f710ce619886e26f7
diff --git a/xos/synchronizer/pull_steps/test_pull_onus.py b/xos/synchronizer/pull_steps/test_pull_onus.py
index de9870c..611e084 100644
--- a/xos/synchronizer/pull_steps/test_pull_onus.py
+++ b/xos/synchronizer/pull_steps/test_pull_onus.py
@@ -258,6 +258,45 @@
self.assertEqual(mock_save.call_count, 1)
+#[SEBA-367] Unit test for blank response recieved from Voltha
+
+ @requests_mock.Mocker()
+ def test_blank_response_received(self, m):
+
+ m.get("http://voltha_url:1234/api/v1/devices", status_code=200, text="")
+ with patch.object(VOLTService.objects, "all") as olt_service_mock, \
+ patch.object(PONPort.objects, "get") as mock_pon_port, \
+ patch.object(OLTDevice.objects, "get") as mock_get, \
+ patch.object(ONUDevice, "save", autospec=True) as mock_save:
+
+ olt_service_mock.return_value = [self.volt_service]
+
+ self.sync_step(model_accessor=self.model_accessor).pull_records()
+
+ olt_service_mock.assert_called()
+ mock_pon_port.assert_not_called()
+ mock_get.assert_not_called()
+ self.assertEqual(mock_save.call_count, 0)
+
+#[SEBA-367] Unit test for invalid json received from Voltha
+
+ @requests_mock.Mocker()
+ def test_invalid_json(self, m):
+
+ m.get("http://voltha_url:1234/api/v1/devices", status_code=200, text="{\"items\" : [host_and_port}")
+ with patch.object(VOLTService.objects, "all") as olt_service_mock, \
+ patch.object(PONPort.objects, "get") as mock_pon_port, \
+ patch.object(OLTDevice.objects, "get") as mock_get, \
+ patch.object(ONUDevice, "save", autospec=True) as mock_save:
+
+ olt_service_mock.return_value = [self.volt_service]
+
+ self.sync_step(model_accessor=self.model_accessor).pull_records()
+
+ olt_service_mock.assert_called()
+ mock_pon_port.assert_not_called()
+ mock_get.assert_not_called()
+ self.assertEqual(mock_save.call_count, 0)
if __name__ == "__main__":
- unittest.main()
\ No newline at end of file
+ unittest.main()