~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_generate_ids.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-01-17 17:21:14 UTC
  • mfrom: (2229.2.5 reserved-ids)
  • Revision ID: pqm@pqm.ubuntu.com-20070117172114-dc75493dad46088c
Ensure reserved ids are never stored

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
        """gen_revision_id should create a revision id matching the regex"""
103
103
        revision_id = generate_ids.gen_revision_id(username, timestamp)
104
104
        self.assertMatchesRe(regex, revision_id)
105
 
        # It should be a utf8 revision_id, not a unicode one
106
 
        self.assertIsInstance(revision_id, str)
107
 
        # gen_revision_id should always return ascii revision ids.
108
 
        revision_id.decode('ascii')
109
105
 
110
106
    def test_timestamp(self):
111
107
        """passing a timestamp should cause it to be used"""
127
123
    def test_gen_revision_id_user(self):
128
124
        """If there is no email, fall back to the whole username"""
129
125
        tail = r'-\d{14}-[a-z0-9]{16}'
130
 
        self.assertGenRevisionId('joe_bar' + tail, 'Joe Bar')
 
126
        self.assertGenRevisionId('joe_bar' + tail,'Joe Bar')
131
127
        self.assertGenRevisionId('joebar' + tail, 'joebar')
132
128
        self.assertGenRevisionId('joe_br' + tail, u'Joe B\xe5r')
133
129
        self.assertGenRevisionId(r'joe_br_user\+joe_bar_foo-bar.com' + tail,
134
130
                                 u'Joe B\xe5r <user+Joe_Bar_Foo-Bar.com>')
135
 
 
136
 
    def test_revision_ids_are_ascii(self):
137
 
        """gen_revision_id should always return an ascii revision id."""
138
 
        tail = r'-\d{14}-[a-z0-9]{16}'
139
 
        self.assertGenRevisionId('joe_bar' + tail, 'Joe Bar')
140
 
        self.assertGenRevisionId('joe_bar' + tail, u'Joe Bar')
141
 
        self.assertGenRevisionId('joe@foo' + tail, u'Joe Bar <joe@foo>')
142
 
        # We cheat a little with this one, because email-addresses shouldn't
143
 
        # contain non-ascii characters, but generate_ids should strip them
144
 
        # anyway.
145
 
        self.assertGenRevisionId('joe@f' + tail, u'Joe Bar <joe@f\xb6>')