def build_update(namespace,
                 table,
                 key,
                 timestamp,
                 fields=None,
                 is_delete=False):
    identifier = Identifier(namespace, table, key)
    return Update(identifier=identifier,
                  timestamp=timestamp,
                  fields=fields,
                  is_delete=is_delete)
 def test_set_fields(self):
     identifier = Identifier(namespace="test", table="test", key=uuid4())
     document = Update(identifier, timestamp=time(), fields=[Field("foo", "bar")])
     assert_that(document.fields, contains(Field("foo", "bar")))
     document.fields = [Field("one", 1), Field("two", 2)]
     assert_that(document.fields, contains_inanyorder(Field("one", 1), Field("two", 2)))
 def test_create_update_from_document(self, identifier):
     document = Document(identifier, time(), fields=[Field("a", 2), Field("b", 2), Field("c", 3)])
     update = Update.from_document(document, is_delete=True)
     assert update.identifier == document.identifier
     assert update.timestamp == document.timestamp
     assert update.fields == document.fields
 def _build_save_update(existing_document):
     if existing_document:
         return Update.from_document(existing_document, is_delete=False)
     else:
         return None
 def _build_delete_update(log_entry):
     update = Update()
     update.is_delete = True
     update.identifier = log_entry.logged_identifier
     update.timestamp = log_entry.timestamp
     return update
 def _build_save_update(existing_document):
     if existing_document:
         return Update.from_document(existing_document, is_delete=False)
     else:
         return None
 def _build_delete_update(log_entry):
     update = Update()
     update.is_delete = True
     update.identifier = log_entry.logged_identifier
     update.timestamp = log_entry.timestamp
     return update
 def _to_update(self, data):
     # it is impossible to retrieve delete updates from Elasticsearch. All updates are save only.
     return Update.from_document(data, is_delete=False)