示例#1
0
    def test_create_note(self):
        # clone record
        fields = {
            'note_record_id': ' test_domain/note_1',
            'person_record_id': '  test_domain/person_1 '
        }

        # source_date should be required.
        raises(AssertionError, importer.create_note, 'haiti', fields)

        # With source_date, the conversion should succeed.
        fields['source_date'] = '2010-01-02T12:34:56Z'
        note = importer.create_note('haiti', fields)
        assert note.record_id == 'test_domain/note_1'
        assert note.person_record_id == 'test_domain/person_1'
        assert note.status == ''
        assert note.key().kind() == 'Note'
        assert note.key().id() == None
        assert note.key().name() == 'haiti:test_domain/note_1'

        # original record
        fields = {
            'person_record_id': '  test_domain/person_1 ',
            'source_date': '2010-01-02T03:04:05Z'
        }
        note = importer.create_note('haiti', fields)
        assert note.record_id.startswith('haiti.%s/note.' % model.HOME_DOMAIN)
        assert note.person_record_id == 'test_domain/person_1'
示例#2
0
def create_note(note_dict):
    # TODO(kpy): Pass a subdomain argument to importer.create_note.
    try:
        return importer.create_note(note_dict)
    except AssertionError:
        pass
    try:
        return importer.create_note(note_dict, requires_key=False)
    except AssertionError:
        logging.info('skipping note %s as it cannot be made valid', note_dict)
        return None
示例#3
0
def create_note(note_dict):
    # TODO(kpy): Pass a subdomain argument to importer.create_note.
    try:
        return importer.create_note(note_dict)
    except AssertionError:
        pass
    try:
        return importer.create_note(note_dict, requires_key=False)
    except AssertionError:
        logging.info("skipping note %s as it cannot be made valid", note_dict)
        return None
def create_note(note_dict):
  try:
    return importer.create_note(note_dict)
  except AssertionError:
    pass
  try:
    return importer.create_note(note_dict, requires_key=False)
  except AssertionError:
    logging.info(
          'skipping note %s as it cannot be made valid', note_dict)
    return None
  def test_create_note(self):
    # clone record
    fields = {"note_record_id": " test_domain/note_1",
              "person_record_id": "  test_domain/person_1 "}
    note = importer.create_note(fields)
    self.assertEqual(note.note_record_id, "test_domain/note_1")
    self.assertEqual(note.person_record_id, "test_domain/person_1")
    self.assertEqual(note.status, "")
    self.assertEqual(note.key().kind(), 'Note')
    self.assertEqual(note.key().id(), None)
    self.assertEqual(note.key().name(), 'test_domain/note_1')

    # original record
    fields = {"note_record_id": model.HOME_DOMAIN + '/note.78',
              "person_record_id": "  test_domain/person_1 "}
    note = importer.create_note(fields)
    self.assertEqual(note.key().kind(), 'Note')
    self.assertEqual(note.key().id(), 78)
    self.assertEqual(note.key().name(), None)
示例#6
0
    def test_create_note(self):
        # clone record
        fields = {'note_record_id': ' test_domain/note_1',
                  'person_record_id': '  test_domain/person_1 '}

        # source_date should be required.
        raises(AssertionError, importer.create_note, 'haiti', fields)

        # With source_date, the conversion should succeed.
        fields['source_date'] = '2010-01-02T12:34:56Z'
        note = importer.create_note('haiti', fields)
        assert note.record_id == 'test_domain/note_1'
        assert note.person_record_id == 'test_domain/person_1'
        assert note.status == ''
        assert note.key().kind() == 'Note'
        assert note.key().id() == None
        assert note.key().name() == 'haiti:test_domain/note_1'

        # original record
        fields = {'person_record_id': '  test_domain/person_1 ',
                  'source_date': '2010-01-02T03:04:05Z'}
        note = importer.create_note('haiti', fields)
        assert note.record_id.startswith('haiti.%s/note.' % model.HOME_DOMAIN)
        assert note.person_record_id == 'test_domain/person_1'