def test_add_notification():
    notification = Notification(pytest.session)
    notification.notify_uri = "https://api.figo.me/callback"
    notification.observe_key = "/rest/transactions"
    notification.state = "4HgwtQP0jsjdz79h"
    response = pytest.session.add_notification(notification)
    pytest.notification = response
    assert response.notification_id is not None
Пример #2
0
def test_create_update_delete_notification(figo_session):
    """
    This test sometimes fails, when run for different versions in parallel, e.g. on travis
    It happens because the notification id will always be the same for the demo client.
    This will be solved with running tests against an enhanced sandbox.
    """
    state_version = "V{0}".format(platform.python_version())
    added_notification = figo_session.add_notification(
        Notification.from_dict(figo_session, dict(observe_key="/rest/transactions",
                                                  notify_uri="http://figo.me/test",
                                                  state=state_version)))

    assert added_notification.observe_key == "/rest/transactions"
    assert added_notification.notify_uri == "http://figo.me/test"
    assert added_notification.state == state_version

    print("\n##############")
    print("id: {0}, {1}".format(added_notification.notification_id, added_notification.state))

    added_notification.state = state_version + "_modified"
    modified_notification = figo_session.modify_notification(added_notification)
    assert modified_notification.observe_key == "/rest/transactions"
    assert modified_notification.notify_uri == "http://figo.me/test"
    assert modified_notification.state == state_version + "_modified"

    print("id: {0}, {1}".format(modified_notification.notification_id, modified_notification.state))

    figo_session.remove_notification(modified_notification.notification_id)
    with pytest.raises(FigoException):
        deleted_notification = figo_session.get_notification(modified_notification.notification_id)
        print("id: {0}, {1}".format(
            deleted_notification.notification_id, deleted_notification.state))
        print("#"*10)
Пример #3
0
 def test_create_notification_from_dict(self):
     data = {
         "notification_id": "N1.7",
         "notify_uri": "https://api.figo.me/callback",
         "observe_key": "/rest/transactions?include_pending=0",
         "state": "cjLaN3lONdeLJQH3"
     }
     notification = Notification.from_dict(self.sut, data)
     self.assertTrue(isinstance(notification, Notification))
Пример #4
0
def test_create_notification_from_dict(figo_session):
    data = {
        "notification_id": "N1.7",
        "notify_uri": "https://api.figo.me/callback",
        "observe_key": "/rest/transactions?include_pending=0",
        "state": "cjLaN3lONdeLJQH3"
    }
    notification = Notification.from_dict(figo_session, data)
    assert isinstance(notification, Notification)
Пример #5
0
def test_create_notification_from_dict(figo_session):
    data = {
        "notification_id": "N1.7",
        "notify_uri": "https://api.figo.me/callback",
        "observe_key": "/rest/transactions?include_pending=0",
        "state": "cjLaN3lONdeLJQH3",
    }
    notification = Notification.from_dict(figo_session, data)
    assert isinstance(notification, Notification)
    print(notification)
Пример #6
0
    def test_create_update_delete_notification(self):
        added_notification = self.sut.add_notification(Notification.from_dict(self.sut, dict(observe_key="/rest/transactions", notify_uri="http://figo.me/test", state="qwe")))
        self.assertEqual(added_notification.observe_key, "/rest/transactions")
        self.assertEqual(added_notification.notify_uri, "http://figo.me/test")
        self.assertEqual(added_notification.state, "qwe")

        added_notification.state = "asd"
        modified_notification = self.sut.modify_notification(added_notification)
        self.assertEqual(modified_notification.observe_key, "/rest/transactions")
        self.assertEqual(modified_notification.notify_uri, "http://figo.me/test")
        self.assertEqual(modified_notification.state, "asd")

        self.sut.remove_notification(modified_notification.notification_id)
        self.assertEqual(self.sut.get_notification(modified_notification.notification_id), None)
Пример #7
0
    def test_create_update_delete_notification(self):
        added_notification = self.sut.add_notification(
            Notification.from_dict(
                self.sut,
                dict(observe_key="/rest/transactions",
                     notify_uri="http://figo.me/test",
                     state="qwe")))
        self.assertEqual(added_notification.observe_key, "/rest/transactions")
        self.assertEqual(added_notification.notify_uri, "http://figo.me/test")
        self.assertEqual(added_notification.state, "qwe")

        added_notification.state = "asd"
        modified_notification = self.sut.modify_notification(
            added_notification)
        self.assertEqual(modified_notification.observe_key,
                         "/rest/transactions")
        self.assertEqual(modified_notification.notify_uri,
                         "http://figo.me/test")
        self.assertEqual(modified_notification.state, "asd")

        self.sut.remove_notification(modified_notification.notification_id)
        self.assertEqual(
            self.sut.get_notification(modified_notification.notification_id),
            None)