mirror of https://github.com/zulip/zulip.git
parent
e51d98cd96
commit
dcc831f767
|
@ -46,9 +46,9 @@ class CountStat(object):
|
||||||
else: # frequency == CountStat.DAY
|
else: # frequency == CountStat.DAY
|
||||||
self.interval = timedelta(days=1)
|
self.interval = timedelta(days=1)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<CountStat: %s>" % (self.property,)
|
return "<CountStat: %s>" % (self.property,)
|
||||||
|
|
||||||
class LoggingCountStat(CountStat):
|
class LoggingCountStat(CountStat):
|
||||||
def __init__(self, property, output_table, frequency):
|
def __init__(self, property, output_table, frequency):
|
||||||
|
|
|
@ -18,9 +18,9 @@ class FillState(models.Model):
|
||||||
|
|
||||||
last_modified = models.DateTimeField(auto_now=True) # type: datetime.datetime
|
last_modified = models.DateTimeField(auto_now=True) # type: datetime.datetime
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<FillState: %s %s %s>" % (self.property, self.end_time, self.state)
|
return "<FillState: %s %s %s>" % (self.property, self.end_time, self.state)
|
||||||
|
|
||||||
# The earliest/starting end_time in FillState
|
# The earliest/starting end_time in FillState
|
||||||
# We assume there is at least one realm
|
# We assume there is at least one realm
|
||||||
|
@ -42,9 +42,9 @@ def last_successful_fill(property):
|
||||||
class Anomaly(models.Model):
|
class Anomaly(models.Model):
|
||||||
info = models.CharField(max_length=1000) # type: Text
|
info = models.CharField(max_length=1000) # type: Text
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<Anomaly: %s... %s>" % (self.info, self.id)
|
return "<Anomaly: %s... %s>" % (self.info, self.id)
|
||||||
|
|
||||||
class BaseCount(models.Model):
|
class BaseCount(models.Model):
|
||||||
# Note: When inheriting from BaseCount, you may want to rearrange
|
# Note: When inheriting from BaseCount, you may want to rearrange
|
||||||
|
@ -64,9 +64,9 @@ class InstallationCount(BaseCount):
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
unique_together = ("property", "subgroup", "end_time")
|
unique_together = ("property", "subgroup", "end_time")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<InstallationCount: %s %s %s>" % (self.property, self.subgroup, self.value)
|
return "<InstallationCount: %s %s %s>" % (self.property, self.subgroup, self.value)
|
||||||
|
|
||||||
class RealmCount(BaseCount):
|
class RealmCount(BaseCount):
|
||||||
realm = models.ForeignKey(Realm)
|
realm = models.ForeignKey(Realm)
|
||||||
|
@ -75,9 +75,9 @@ class RealmCount(BaseCount):
|
||||||
unique_together = ("realm", "property", "subgroup", "end_time")
|
unique_together = ("realm", "property", "subgroup", "end_time")
|
||||||
index_together = ["property", "end_time"]
|
index_together = ["property", "end_time"]
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<RealmCount: %s %s %s %s>" % (self.realm, self.property, self.subgroup, self.value)
|
return "<RealmCount: %s %s %s %s>" % (self.realm, self.property, self.subgroup, self.value)
|
||||||
|
|
||||||
class UserCount(BaseCount):
|
class UserCount(BaseCount):
|
||||||
user = models.ForeignKey(UserProfile)
|
user = models.ForeignKey(UserProfile)
|
||||||
|
@ -89,9 +89,9 @@ class UserCount(BaseCount):
|
||||||
# aggregating from users to realms
|
# aggregating from users to realms
|
||||||
index_together = ["property", "realm", "end_time"]
|
index_together = ["property", "realm", "end_time"]
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<UserCount: %s %s %s %s>" % (self.user, self.property, self.subgroup, self.value)
|
return "<UserCount: %s %s %s %s>" % (self.user, self.property, self.subgroup, self.value)
|
||||||
|
|
||||||
class StreamCount(BaseCount):
|
class StreamCount(BaseCount):
|
||||||
stream = models.ForeignKey(Stream)
|
stream = models.ForeignKey(Stream)
|
||||||
|
@ -103,6 +103,6 @@ class StreamCount(BaseCount):
|
||||||
# aggregating from streams to realms
|
# aggregating from streams to realms
|
||||||
index_together = ["property", "realm", "end_time"]
|
index_together = ["property", "realm", "end_time"]
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<StreamCount: %s %s %s %s %s>" % (self.stream, self.property, self.subgroup, self.value, self.id)
|
return "<StreamCount: %s %s %s %s %s>" % (self.stream, self.property, self.subgroup, self.value, self.id)
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Confirmation(models.Model):
|
||||||
MULTIUSE_INVITE = 6
|
MULTIUSE_INVITE = 6
|
||||||
type = models.PositiveSmallIntegerField() # type: int
|
type = models.PositiveSmallIntegerField() # type: int
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return '<Confirmation: %s>' % (self.content_object,)
|
return '<Confirmation: %s>' % (self.content_object,)
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ exclude_lines =
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
# Don't require coverage for test suite AssertionError -- they're usually for clarity
|
# Don't require coverage for test suite AssertionError -- they're usually for clarity
|
||||||
raise AssertionError
|
raise AssertionError
|
||||||
# Don't require coverage for __unicode__ statements just used for printing
|
# Don't require coverage for __str__ statements just used for printing
|
||||||
def __unicode__[(]self[)]:
|
def __str__[(]self[)]:
|
||||||
|
|
||||||
[run]
|
[run]
|
||||||
omit =
|
omit =
|
||||||
|
|
|
@ -222,9 +222,9 @@ class Realm(models.Model):
|
||||||
ret[k] = v
|
ret[k] = v
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<Realm: %s %s>" % (self.string_id, self.id)
|
return "<Realm: %s %s>" % (self.string_id, self.id)
|
||||||
|
|
||||||
@cache_with_key(get_realm_emoji_cache_key, timeout=3600*24*7)
|
@cache_with_key(get_realm_emoji_cache_key, timeout=3600*24*7)
|
||||||
def get_emoji(self):
|
def get_emoji(self):
|
||||||
|
@ -383,9 +383,9 @@ class RealmEmoji(models.Model):
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
unique_together = ("realm", "name")
|
unique_together = ("realm", "name")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<RealmEmoji(%s): %s %s>" % (self.realm.string_id, self.name, self.file_name)
|
return "<RealmEmoji(%s): %s %s>" % (self.realm.string_id, self.name, self.file_name)
|
||||||
|
|
||||||
def get_realm_emoji_uncached(realm):
|
def get_realm_emoji_uncached(realm):
|
||||||
# type: (Realm) -> Dict[Text, Dict[str, Any]]
|
# type: (Realm) -> Dict[Text, Dict[str, Any]]
|
||||||
|
@ -442,9 +442,9 @@ class RealmFilter(models.Model):
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
unique_together = ("realm", "pattern")
|
unique_together = ("realm", "pattern")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<RealmFilter(%s): %s %s>" % (self.realm.string_id, self.pattern, self.url_format_string)
|
return "<RealmFilter(%s): %s %s>" % (self.realm.string_id, self.pattern, self.url_format_string)
|
||||||
|
|
||||||
def get_realm_filters_cache_key(realm_id):
|
def get_realm_filters_cache_key(realm_id):
|
||||||
# type: (int) -> Text
|
# type: (int) -> Text
|
||||||
|
@ -703,9 +703,9 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<UserProfile: %s %s>" % (self.email, self.realm)
|
return "<UserProfile: %s %s>" % (self.email, self.realm)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_incoming_webhook(self):
|
def is_incoming_webhook(self):
|
||||||
|
@ -890,9 +890,9 @@ class Stream(models.Model):
|
||||||
date_created = models.DateTimeField(default=timezone_now) # type: datetime.datetime
|
date_created = models.DateTimeField(default=timezone_now) # type: datetime.datetime
|
||||||
deactivated = models.BooleanField(default=False) # type: bool
|
deactivated = models.BooleanField(default=False) # type: bool
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<Stream: %s>" % (self.name,)
|
return "<Stream: %s>" % (self.name,)
|
||||||
|
|
||||||
def is_public(self):
|
def is_public(self):
|
||||||
# type: () -> bool
|
# type: () -> bool
|
||||||
|
@ -942,10 +942,10 @@ class Recipient(models.Model):
|
||||||
# Raises KeyError if invalid
|
# Raises KeyError if invalid
|
||||||
return self._type_names[self.type]
|
return self._type_names[self.type]
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
display_recipient = get_display_recipient(self)
|
display_recipient = get_display_recipient(self)
|
||||||
return u"<Recipient: %s (%d, %s)>" % (display_recipient, self.type_id, self.type)
|
return "<Recipient: %s (%d, %s)>" % (display_recipient, self.type_id, self.type)
|
||||||
|
|
||||||
class MutedTopic(models.Model):
|
class MutedTopic(models.Model):
|
||||||
user_profile = models.ForeignKey(UserProfile, on_delete=CASCADE)
|
user_profile = models.ForeignKey(UserProfile, on_delete=CASCADE)
|
||||||
|
@ -956,16 +956,16 @@ class MutedTopic(models.Model):
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
unique_together = ('user_profile', 'stream', 'topic_name')
|
unique_together = ('user_profile', 'stream', 'topic_name')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<MutedTopic: (%s, %s, %s)>" % (self.user_profile.email, self.stream.name, self.topic_name)
|
return "<MutedTopic: (%s, %s, %s)>" % (self.user_profile.email, self.stream.name, self.topic_name)
|
||||||
|
|
||||||
class Client(models.Model):
|
class Client(models.Model):
|
||||||
name = models.CharField(max_length=30, db_index=True, unique=True) # type: Text
|
name = models.CharField(max_length=30, db_index=True, unique=True) # type: Text
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<Client: %s>" % (self.name,)
|
return "<Client: %s>" % (self.name,)
|
||||||
|
|
||||||
get_client_cache = {} # type: Dict[Text, Client]
|
get_client_cache = {} # type: Dict[Text, Client]
|
||||||
def get_client(name):
|
def get_client(name):
|
||||||
|
@ -1123,11 +1123,11 @@ class AbstractMessage(models.Model):
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
display_recipient = get_display_recipient(self.recipient)
|
display_recipient = get_display_recipient(self.recipient)
|
||||||
return u"<%s: %s / %s / %r>" % (self.__class__.__name__, display_recipient,
|
return "<%s: %s / %s / %r>" % (self.__class__.__name__, display_recipient,
|
||||||
self.subject, self.sender)
|
self.subject, self.sender)
|
||||||
|
|
||||||
|
|
||||||
class ArchivedMessage(AbstractMessage):
|
class ArchivedMessage(AbstractMessage):
|
||||||
|
@ -1330,11 +1330,11 @@ class AbstractUserMessage(models.Model):
|
||||||
if flags & (2 ** i)
|
if flags & (2 ** i)
|
||||||
]
|
]
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
display_recipient = get_display_recipient(self.message.recipient)
|
display_recipient = get_display_recipient(self.message.recipient)
|
||||||
return u"<%s: %s / %s (%s)>" % (self.__class__.__name__, display_recipient,
|
return "<%s: %s / %s (%s)>" % (self.__class__.__name__, display_recipient,
|
||||||
self.user_profile.email, self.flags_list())
|
self.user_profile.email, self.flags_list())
|
||||||
|
|
||||||
|
|
||||||
class ArchivedUserMessage(AbstractUserMessage):
|
class ArchivedUserMessage(AbstractUserMessage):
|
||||||
|
@ -1373,9 +1373,9 @@ class AbstractAttachment(models.Model):
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<%s: %s>" % (self.__class__.__name__, self.file_name,)
|
return "<%s: %s>" % (self.__class__.__name__, self.file_name,)
|
||||||
|
|
||||||
|
|
||||||
class ArchivedAttachment(AbstractAttachment):
|
class ArchivedAttachment(AbstractAttachment):
|
||||||
|
@ -1455,9 +1455,9 @@ class Subscription(models.Model):
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
unique_together = ("user_profile", "recipient")
|
unique_together = ("user_profile", "recipient")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<Subscription: %r -> %s>" % (self.user_profile, self.recipient)
|
return "<Subscription: %r -> %s>" % (self.user_profile, self.recipient)
|
||||||
|
|
||||||
@cache_with_key(user_profile_by_id_cache_key, timeout=3600*24*7)
|
@cache_with_key(user_profile_by_id_cache_key, timeout=3600*24*7)
|
||||||
def get_user_profile_by_id(uid):
|
def get_user_profile_by_id(uid):
|
||||||
|
@ -1839,8 +1839,8 @@ class ScheduledEmail(AbstractScheduledJob):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
return u"<ScheduledEmail: %s %s %s>" % (self.type, self.user or self.address,
|
return "<ScheduledEmail: %s %s %s>" % (self.type, self.user or self.address,
|
||||||
self.scheduled_timestamp)
|
self.scheduled_timestamp)
|
||||||
|
|
||||||
EMAIL_TYPES = {
|
EMAIL_TYPES = {
|
||||||
'followup_day1': ScheduledEmail.WELCOME,
|
'followup_day1': ScheduledEmail.WELCOME,
|
||||||
|
@ -1862,12 +1862,12 @@ class RealmAuditLog(models.Model):
|
||||||
backfilled = models.BooleanField(default=False) # type: bool
|
backfilled = models.BooleanField(default=False) # type: bool
|
||||||
extra_data = models.TextField(null=True) # type: Optional[Text]
|
extra_data = models.TextField(null=True) # type: Optional[Text]
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
if self.modified_user is not None:
|
if self.modified_user is not None:
|
||||||
return u"<RealmAuditLog: %s %s %s>" % (self.modified_user, self.event_type, self.event_time)
|
return "<RealmAuditLog: %s %s %s>" % (self.modified_user, self.event_type, self.event_time)
|
||||||
if self.modified_stream is not None:
|
if self.modified_stream is not None:
|
||||||
return u"<RealmAuditLog: %s %s %s>" % (self.modified_stream, self.event_type, self.event_time)
|
return "<RealmAuditLog: %s %s %s>" % (self.modified_stream, self.event_type, self.event_time)
|
||||||
return "<RealmAuditLog: %s %s %s>" % (self.realm, self.event_type, self.event_time)
|
return "<RealmAuditLog: %s %s %s>" % (self.realm, self.event_type, self.event_time)
|
||||||
|
|
||||||
class UserHotspot(models.Model):
|
class UserHotspot(models.Model):
|
||||||
|
|
|
@ -623,7 +623,7 @@ class BugdownTest(ZulipTestCase):
|
||||||
url_format_string=url_format_string)
|
url_format_string=url_format_string)
|
||||||
realm_filter.save()
|
realm_filter.save()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
realm_filter.__unicode__(),
|
realm_filter.__str__(),
|
||||||
'<RealmFilter(zulip): #(?P<id>[0-9]{2,8})'
|
'<RealmFilter(zulip): #(?P<id>[0-9]{2,8})'
|
||||||
' https://trac.zulip.net/ticket/%(id)s>')
|
' https://trac.zulip.net/ticket/%(id)s>')
|
||||||
|
|
||||||
|
|
|
@ -328,12 +328,12 @@ class PersonalMessagesTest(ZulipTestCase):
|
||||||
|
|
||||||
with mock.patch('zerver.models.get_display_recipient', return_value='recip'):
|
with mock.patch('zerver.models.get_display_recipient', return_value='recip'):
|
||||||
self.assertEqual(str(message),
|
self.assertEqual(str(message),
|
||||||
u'<Message: recip / / '
|
'<Message: recip / / '
|
||||||
'<UserProfile: test@zulip.com <Realm: zulip 1>>>')
|
'<UserProfile: test@zulip.com <Realm: zulip 1>>>')
|
||||||
|
|
||||||
user_message = most_recent_usermessage(user_profile)
|
user_message = most_recent_usermessage(user_profile)
|
||||||
self.assertEqual(str(user_message),
|
self.assertEqual(str(user_message),
|
||||||
u'<UserMessage: recip / test@zulip.com ([])>'
|
'<UserMessage: recip / test@zulip.com ([])>'
|
||||||
)
|
)
|
||||||
|
|
||||||
@slow("checks several profiles")
|
@slow("checks several profiles")
|
||||||
|
|
|
@ -53,10 +53,10 @@ class TestClientModel(ZulipTestCase):
|
||||||
def test_client_stringification(self):
|
def test_client_stringification(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
'''
|
'''
|
||||||
This test is designed to cover __unicode__ method for Client.
|
This test is designed to cover __str__ method for Client.
|
||||||
'''
|
'''
|
||||||
client = make_client('some_client')
|
client = make_client('some_client')
|
||||||
self.assertEqual(str(client), u'<Client: some_client>')
|
self.assertEqual(str(client), '<Client: some_client>')
|
||||||
|
|
||||||
class UserPresenceModelTests(ZulipTestCase):
|
class UserPresenceModelTests(ZulipTestCase):
|
||||||
def test_date_logic(self):
|
def test_date_logic(self):
|
||||||
|
|
|
@ -2146,7 +2146,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||||
self.assert_adding_subscriptions_for_principal(invitee_email, invitee_realm, invite_streams)
|
self.assert_adding_subscriptions_for_principal(invitee_email, invitee_realm, invite_streams)
|
||||||
subscription = self.get_subscription(user_profile, invite_streams[0])
|
subscription = self.get_subscription(user_profile, invite_streams[0])
|
||||||
|
|
||||||
with mock.patch('zerver.models.Recipient.__unicode__', return_value='recip'):
|
with mock.patch('zerver.models.Recipient.__str__', return_value='recip'):
|
||||||
self.assertEqual(str(subscription),
|
self.assertEqual(str(subscription),
|
||||||
u'<Subscription: '
|
u'<Subscription: '
|
||||||
'<UserProfile: %s <Realm: zulip 1>> -> recip>' % (self.example_email('iago'),))
|
'<UserProfile: %s <Realm: zulip 1>> -> recip>' % (self.example_email('iago'),))
|
||||||
|
|
Loading…
Reference in New Issue