def test_update_prefix_properties(self): prefix.add_prefix_properties(TestPerson, 'name') test_person = TestPerson(name='John') prefix.update_prefix_properties(test_person) self.assertEqual(getattr(test_person, 'name_n_'), 'JOHN') self.assertEqual(getattr(test_person, 'name_n1_'), 'J') self.assertEqual(getattr(test_person, 'name_n2_'), 'JO')
def test_update_prefix_properties(self): prefix.add_prefix_properties(TestPerson, 'name') test_person = TestPerson(name='John') prefix.update_prefix_properties(test_person) assert test_person.name_n_ == 'JOHN' assert test_person.name_n1_ == 'J' assert test_person.name_n2_ == 'JO'
def test_add_prefix_properties(self): prefix_properties = ['name'] prefix_types = ['_n_', '_n1_', '_n2_'] all_properties = ['name', 'name_n1_', 'name_n2_', 'name_n_'] prefix.add_prefix_properties(TestPerson, 'name') # Test the list of prefix properties was recorded assert TestPerson._prefix_properties == prefix_properties # Test all prefix properties have been added for prefix_type in prefix_types: assert hasattr(TestPerson, 'name' + prefix_type) # Test that the model class was updated assert sorted(TestPerson.properties()) == all_properties
def test_add_prefix_properties(self): prefix_properties = ['name'] prefix_types = ['_n_', '_n1_', '_n2_'] all_properties = ['name', 'name_n1_', 'name_n2_', 'name_n_'] prefix.add_prefix_properties(TestPerson, 'name') # Test the list of prefix properties was recorded self.assertEqual(TestPerson._prefix_properties, prefix_properties) # Test all prefix properties have been added for prefix_type in prefix_types: self.assertTrue(hasattr(TestPerson, 'name' + prefix_type)) # Test that the model class was updated self.assertEqual(sorted(TestPerson.properties()), all_properties)
self.latest_status_source_date = status_source_date self.put() def put_new(self): """Write the new person record to datastore. Increments person_counter because a new record is created. Logs user actions is updated too. We should never call this method against an existing record.""" db.put(self) UsageCounter.increment_counter(self.repo, ['person']) UserActionLog.put_new('add', self, copy_properties=False) # Old indexing # TODO(ryok): This is obsolete. Remove it. prefix.add_prefix_properties(Person, 'given_name', 'family_name', 'home_street', 'home_neighborhood', 'home_city', 'home_state', 'home_postal_code') class Note(Base): """The datastore entity kind for storing a PFIF note record. Never call Note() directly; use Note.create_clone() or Note.create_original().""" # The entry_date should update every time a record is re-imported. entry_date = db.DateTimeProperty(required=True) person_record_id = db.StringProperty(required=True) # Use this field to store the person_record_id of a duplicate Person entry. linked_person_record_id = db.StringProperty(default='')
for note in self.get_notes(): if modified_note and modified_note.note_record_id == note.record_id: note = modified_note if note.status and not note.hidden: status = note.status status_source_date = note.source_date if status != self.latest_status: self.latest_status = status self.latest_status_source_date = status_source_date self.put() # Old indexing # TODO(ryok): This is obsolete. Remove it. prefix.add_prefix_properties( Person, 'given_name', 'family_name', 'home_street', 'home_neighborhood', 'home_city', 'home_state', 'home_postal_code') class Note(Base): """The datastore entity kind for storing a PFIF note record. Never call Note() directly; use Note.create_clone() or Note.create_original().""" # The entry_date should update every time a record is re-imported. entry_date = db.DateTimeProperty(required=True) person_record_id = db.StringProperty(required=True) # Use this field to store the person_record_id of a duplicate Person entry. linked_person_record_id = db.StringProperty(default='')
if note.status and not note.hidden: status = note.status status_source_date = note.source_date if status != self.latest_status: self.latest_status = status self.latest_status_source_date = status_source_date self.put() # Old indexing # TODO(ryok): This is obsolete. Remove it. prefix.add_prefix_properties( Person, "given_name", "family_name", "home_street", "home_neighborhood", "home_city", "home_state", "home_postal_code", ) class Note(Base): """The datastore entity kind for storing a PFIF note record. Never call Note() directly; use Note.create_clone() or Note.create_original().""" # The entry_date should update every time a record is re-imported. entry_date = db.DateTimeProperty(required=True) person_record_id = db.StringProperty(required=True)
if (self.latest_status_source_date is None or note.source_date >= self.latest_status_source_date): self.latest_status = note.status self.latest_status_source_date = note.source_date def update_index(self, which_indexing): #setup new indexing if 'new' in which_indexing: indexing.update_index_properties(self) # setup old indexing if 'old' in which_indexing: prefix.update_prefix_properties(self) #old indexing prefix.add_prefix_properties( Pet, 'first_name', 'last_name', 'home_street', 'home_neighborhood', 'home_city', 'home_state', 'home_postal_code') class Note(Base): """The datastore entity kind for storing a PFIF note record. Never call Note() directly; use Note.create_clone() or Note.create_original().""" FETCH_LIMIT = 200 # The entry_date should update every time a record is re-imported. entry_date = db.DateTimeProperty(required=True) person_record_id = db.StringProperty(required=True) # Use this field to store the person_record_id of a duplicate Person entry.
#setup new indexing if 'new' in which_indexing: indexing.update_index_properties(self) # setup old indexing if 'old' in which_indexing: prefix.update_prefix_properties(self) #new inedxing indexing.add_fields_to_index_by_prefix_properties(Person, 'first_name', 'last_name'); indexing.add_fields_to_index_properties(Person, 'first_name', 'last_name'); #old indexing prefix.add_prefix_properties( Person, 'first_name', 'last_name', 'home_street', 'home_neighborhood', 'home_city', 'home_state', 'home_zip') class Note(db.Model, Base): """The datastore entity kind for storing a PFIF note record.""" # The entry_date should update every time a record is re-imported. entry_date = db.DateTimeProperty(auto_now=True) person_record_id = db.StringProperty(required=True) # Use this field to store the person_record_id of a duplicate Person entry. linked_person_record_id = db.StringProperty(default='') author_name = db.StringProperty(default='', multiline=True)