コード例 #1
0
 def create_or_update(self, payload, timestamp):
     payload = serialize_swift_account_notification(payload)
     try:
         self.index_helper.save_document(
             payload,
             version=self.get_version(payload, timestamp))
     except Exception as exc:
         LOG.error(_LE('Error saving account %(id)s '
                       'in index. Error: %(exc)s') %
                   {'id': payload['id'], 'exc': exc})
コード例 #2
0
 def create_or_update(self, event_type, payload, timestamp):
     serialized_account = serialize_swift_account_notification(payload)
     try:
         self.index_helper.save_document(
             serialized_account,
             version=self.get_version(serialized_account, timestamp))
         return pipeline.IndexItem(self.index_helper.plugin,
                                   event_type,
                                   payload,
                                   serialized_account
                                   )
     except Exception as exc:
         LOG.error('Error saving account %(id)s '
                   'in index. Error: %(exc)s' %
                   {'id': payload['id'], 'exc': exc})
コード例 #3
0
    def test_swift_account_notification_serialize(self):
        notification = _notification_account_fixture(
            ID1,
            project_name='admin',
            project_id=ID1,
            project_domain_id='default',
            updated_at=DATE1,
        )

        expected = {
            'id': ID1,
            'name': 'admin',
            'updated_at': DATE1,
            'domain_id': 'default'
        }

        serialized = swift_plugin.serialize_swift_account_notification(
            notification)
        self.assertEqual(expected, serialized)
コード例 #4
0
    def test_swift_account_notification_serialize(self):
        notification = _notification_account_fixture(
            ID1,
            project_name='admin',
            project_id=ID1,
            project_domain_id='default',
            updated_at=DATE1,
        )

        expected = {
            'id': ID1,
            'name': 'admin',
            'updated_at': DATE1,
            'domain_id': 'default'
        }

        serialized = swift_plugin.serialize_swift_account_notification(
            notification)
        self.assertEqual(expected, serialized)