Esempio n. 1
0
 def test_notify_with_no_agent_notification_connections(self):
     settings.AGENT_CONFIG.notification_connections = []
     data = {
         "name": "test",
         "condition": V1StatusCondition(
             type=V1Statuses.FAILED, status=True
         ).to_dict(),
         "connections": ["test1", "test2"],
     }
     response = self.client.post(self.base_url, json=data)
     assert response.status_code == 400
Esempio n. 2
0
    def test_notify_with_no_notifications(self):
        data = {
            "name": "test",
            "condition": V1StatusCondition(
                type=V1Statuses.FAILED, status=True
            ).to_dict(),
            "connections": None,
        }
        response = self.client.post(self.base_url, json=data)
        assert response.status_code == 400

        data = {
            "name": "test",
            "condition": V1StatusCondition(
                type=V1Statuses.FAILED, status=True
            ).to_dict(),
            "connections": [],
        }
        response = self.client.post(self.base_url, json=data)
        assert response.status_code == 400
 def test_notify_with_non_recognized_connections(self):
     data = {
         "name":
         "test",
         "condition":
         V1StatusCondition(type=V1Statuses.FAILED, status=True).to_dict(),
         "connections": ["test1", "test2"],
     }
     with patch("polyaxon.agents.spawners.async_spawner.AsyncK8SManager"
                ) as manager_mock:
         manager_mock.return_value.setup.return_value = Future()
         manager_mock.return_value.setup.return_value.set_result(None)
         response = self.client.post(self.base_url, json=data)
         assert response.status_code == 200
 def setUp(self):
     super().setUp()
     self.notification = NotificationSpec(
         kind=self.webhook.notification_key,
         owner="onwer",
         project="project",
         uuid=uuid.uuid4().hex,
         name="test",
         condition=V1StatusCondition(
             type=V1Statuses.FAILED,
             reason="reason",
             message="message",
             last_update_time=now(),
             last_transition_time=now(),
         ),
     )