def test_unicode_event_truncation(db, default_account): emoji_str = u"".join([u"😁" for i in range(300)]) title = "".join(["a" for i in range(2000)]) e = Event( raw_data="", busy=True, all_day=False, read_only=False, uid="x" * 1000, start=datetime(2015, 2, 22, 11, 11), end=datetime(2015, 2, 22, 22, 22), is_owner=True, calendar=default_account.emailed_events_calendar, title=title, location=emoji_str, participants=[], ) e.namespace = default_account.namespace db.session.add(e) db.session.commit() # Both location and title should be properly truncated to their max lengths. # It's ok to have N unicode characters in a VARCHAR(N) field because # the column is uft8-encoded. assert len(e.location) == 255 assert len(e.title) == 1024 assert len(e.uid) == 767 e = RecurringEventOverride( raw_data="", busy=True, all_day=False, read_only=False, uid="y" * 1000, start=datetime(2015, 2, 22, 11, 11), end=datetime(2015, 2, 22, 22, 22), is_owner=True, master_event_uid="z" * 1000, calendar=default_account.emailed_events_calendar, title=title, location=emoji_str, participants=[], ) e.namespace = default_account.namespace db.session.add(e) db.session.commit() assert len(e.location) == 255 assert len(e.title) == 1024 assert len(e.uid) == 767 assert len(e.master_event_uid) == 767
def test_unicode_event_truncation(db, default_account): emoji_str = u"".join([u"😁" for i in range(300)]) title = "".join(["a" for i in range(2000)]) e = Event(raw_data='', busy=True, all_day=False, read_only=False, uid='31418', start=datetime(2015, 2, 22, 11, 11), end=datetime(2015, 2, 22, 22, 22), is_owner=True, calendar=default_account.emailed_events_calendar, title=title, location=emoji_str, participants=[]) e.namespace = default_account.namespace db.session.add(e) db.session.commit() # Both location and title should be properly truncated to their max lengths. # It's ok to have N unicode characters in a VARCHAR(N) field because # the column is uft8-encoded. assert len(e.location) == 255 assert len(e.title) == 1024
def test_unicode_event_truncation(db, default_account): emoji_str = u"".join([u"😁" for i in range(256)]) title = "".join(["a" for i in range(2048)]) e = Event(raw_data='', busy=True, all_day=False, read_only=False, uid='31418', start=datetime(2015, 2, 22, 11, 11), end=datetime(2015, 2, 22, 22, 22), is_owner=True, calendar=default_account.emailed_events_calendar, title=title, location=emoji_str, participants=[]) e.namespace = default_account.namespace db.session.add(e) db.session.commit() # Original location had 256 emoji chars. Emoji in utf-8 are # 4 bytes in length. The field is at most 255 chars, so # 255 / 4 = 63. assert len(e.location) == 63 assert len(e.title) == 1024