Merge lp:~james-w/udd/unicode-everything into lp:udd

Proposed by James Westby on 2012-04-04
Status: Merged
Approved by: Jonathan Lange on 2012-04-04
Approved revision: 571
Merged at revision: 569
Proposed branch: lp:~james-w/udd/unicode-everything
Merge into: lp:udd
Diff against target: 523 lines (+140/-93)
7 files modified
selftest.py (+1/-0)
udd/icommon.py (+62/-59)
udd/scripts/import_package.py (+33/-33)
udd/scripts/requeue_package.py (+1/-0)
udd/scripts/show_failure.py (+1/-1)
udd/tests/test_history_database.py (+33/-0)
udd/tests/test_status_database.py (+9/-0)
To merge this branch: bzr merge lp:~james-w/udd/unicode-everything
Reviewer Review Type Date Requested Status
Jonathan Lange (community) 2012-04-04 Approve on 2012-04-04
Review via email: mp+100842@code.launchpad.net

Commit Message

Use unicode everywhere to make storm happy.

Description of the Change

Hi,

Storm loves unicode. It really, really loves it. It loves it so much
that it won't let two strs be equal after round-tripping through the
database.

It's correct in a way, if a little annoying, so this branch changes
to use unicode rather than bytestrings where they may come in to
context with the database.

There are a lot of changes, but they are 99% boring.

There are three places that bytestrings might have come from:

  1. Literals. I changed most literals to be unicode. Exceptions were things
     related to urls, logging messages, and things that don't get anywhere
     near the database.

  2. Command line input. There are actually only a couple of places that
     a string supplied on the command line may hit the db (e.g. the
     package name passed to import-package). Coercing them to unicode was
     easy, and package names can only be ascii anyway, so we don't really
     have to worry about encodings there.

  3. External systems. launchpadlib happily returns unicode everywhere, so
     we are mostly safe from this, there were just a few extra spots to
     handle.

There are likely some places I missed, but this gets the core functionality
working again.

Thanks,

James

To post a comment you must log in.
lp:~james-w/udd/unicode-everything updated on 2012-04-04
572. By James Westby on 2012-04-04

One more string literal. Thanks jml.

Jonathan Lange (jml) wrote :

Wow. Thanks. Makes it obvious how many duplicated string literals there are in the code base. As I mentioned on IRC, I think you missed converting one usage of 'release'

<jml> james_w: I think you missed one:
     except errors.NotBranchError:
 - ubuntu_b = bstore.get_branch_parts("ubuntu", ubuntu_current_series,
 + ubuntu_b = bstore.get_branch_parts(u"ubuntu", ubuntu_current_series,
                 "release", possible_transports=possible_transports)
 "release" → u"release"

Please fix that and land.

review: Approve
Robert Collins (lifeless) wrote :

A better way to do this might be barry's __future__ incantation, which
IIRC will make string literals unicode by default.IMBW.

-Rob

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'selftest.py'
2--- selftest.py 2012-03-23 16:56:38 +0000
3+++ selftest.py 2012-04-04 17:35:29 +0000
4@@ -47,6 +47,7 @@
5 'udd.tests.test_email_failures',
6 'udd.tests.test_graph_failures',
7 'udd.tests.test_helpers',
8+ 'udd.tests.test_history_database',
9 'udd.tests.test_icommon',
10 'udd.tests.test_idb',
11 'udd.tests.test_import_list',
12
13=== modified file 'udd/icommon.py'
14--- udd/icommon.py 2012-03-23 16:56:38 +0000
15+++ udd/icommon.py 2012-04-04 17:35:29 +0000
16@@ -59,13 +59,13 @@
17 # Distro releases, in chronological order, with continuing trunks like 'sid'
18 # last, as used to set the order of branches in a DistributionBranchSet.
19 db_set_distro_releases = {
20- "ubuntu": ["warty", "hoary", "breezy",
21- "dapper", "edgy", "feisty", "gutsy",
22- "hardy", "intrepid", "jaunty", "karmic",
23- "lucid", "maverick", "natty", "oneiric", "precise",],
24- "debian": ["woody", "sarge", "etch", "lenny",
25- "squeeze", "wheezy",
26- "sid", "experimental"],
27+ u"ubuntu": [u"warty", u"hoary", u"breezy",
28+ u"dapper", u"edgy", u"feisty", u"gutsy",
29+ u"hardy", u"intrepid", u"jaunty", u"karmic",
30+ u"lucid", u"maverick", u"natty", u"oneiric", u"precise",],
31+ u"debian": [u"woody", u"sarge", u"etch", u"lenny",
32+ u"squeeze", u"wheezy",
33+ u"sid", u"experimental"],
34 }
35
36 # Distro releases, in an order such that whenever the _same_ version of a
37@@ -78,47 +78,47 @@
38 # and pulls from other branches when run from scratch as when run incrementally
39 # after each publishing occurred.
40 import_sequence_distro_releases = {
41- "ubuntu": ["warty", "hoary", "breezy",
42- "dapper", "edgy", "feisty", "gutsy",
43- "hardy", "intrepid", "jaunty", "karmic",
44- "lucid", "maverick", "natty", "oneiric", "precise",],
45- "debian": ["sid", "experimental",
46- "woody", "sarge", "etch", "lenny",
47- "squeeze", "wheezy"],
48+ u"ubuntu": [u"warty", u"hoary", u"breezy",
49+ u"dapper", u"edgy", u"feisty", u"gutsy",
50+ u"hardy", u"intrepid", u"jaunty", u"karmic",
51+ u"lucid", u"maverick", u"natty", u"oneiric", u"precise",],
52+ u"debian": [u"sid", u"experimental",
53+ u"woody", u"sarge", u"etch", u"lenny",
54+ u"squeeze", u"wheezy"],
55 }
56
57 # Distro releases known to Launchpad, in the order they should be processed: do
58 # the likely development focus first to fit better with stacking. No etch or
59 # earlier as they aren't on lp
60 lp_distro_releases = {
61- "ubuntu": ["precise", "warty", "hoary", "breezy",
62- "dapper", "edgy", "feisty", "gutsy",
63- "hardy", "intrepid", "jaunty", "karmic",
64- "lucid", "maverick", "natty", "oneiric",],
65- "debian": ["sid", "experimental",
66- "wheezy", "squeeze", "lenny"],
67+ u"ubuntu": [u"precise", u"warty", u"hoary", u"breezy",
68+ u"dapper", u"edgy", u"feisty", u"gutsy",
69+ u"hardy", u"intrepid", u"jaunty", u"karmic",
70+ u"lucid", u"maverick", u"natty", u"oneiric",],
71+ u"debian": [u"sid", u"experimental",
72+ u"wheezy", u"squeeze", u"lenny"],
73 }
74
75 distro_pockets = {
76- "ubuntu": ["release", "security", "proposed", "updates", "backports"],
77- "debian": ["release",],
78+ u"ubuntu": [u"release", u"security", u"proposed", u"updates", u"backports"],
79+ u"debian": [u"release",],
80 }
81
82-default_debian_diff_release = "sid"
83-default_ubuntu_merge_source = "squeeze"
84+default_debian_diff_release = u"sid"
85+default_ubuntu_merge_source = u"squeeze"
86
87
88 def debian_base_url(release):
89- if release in ["hamm", "slink", "potato", "woody", "sarge", "etch"]:
90+ if release in [u"hamm", u"slink", u"potato", u"woody", u"sarge", u"etch"]:
91 return urllib_debian_archive_base_url
92 return urllib_debian_base_url
93
94
95 def make_suite(release, pocket):
96- if pocket == "release":
97+ if pocket == u"release":
98 suite = release
99- elif pocket in ("security", "proposed", "updates", "backports"):
100- suite = "%s-%s" % (release, pocket)
101+ elif pocket in (u"security", u"proposed", u"updates", u"backports"):
102+ suite = u"%s-%s" % (release, pocket)
103 else:
104 assert False, "Unknown pocket: %s" % pocket
105 return suite
106@@ -178,7 +178,7 @@
107 self.version.debian_version)
108 else:
109 version_str = self.version.upstream_version
110- if self.distro == "ubuntu":
111+ if self.distro == u"ubuntu":
112 files_url = (urllib_launchpad_base_url
113 + "ubuntu/%s/+source/%s/%s/+files/"
114 % (self.release, self.name, str(self.version)))
115@@ -208,9 +208,9 @@
116 # Core assumption: packages always have higher versions than their
117 # ancestors... except for backports. Therefore, sort backports after
118 # all non-backports.
119- if a.pocket == "backports" and b.pocket != "backports":
120+ if a.pocket == u"backports" and b.pocket != u"backports":
121 return 1
122- if a.pocket != "backports" and b.pocket == "backports":
123+ if a.pocket != u"backports" and b.pocket == u"backports":
124 return -1
125 # Next sort by version.
126 if a.version < b.version:
127@@ -221,7 +221,7 @@
128 # Sort Debian before Ubuntu, so that synced packages are first imported
129 # into Debian.
130 if a.distro != b.distro:
131- if a.distro == "debian":
132+ if a.distro == u"debian":
133 return -1
134 return 1
135 # From here on, a.distro == b.distro
136@@ -838,7 +838,10 @@
137
138
139 def make_datetime(strified):
140- return datetime.strptime(strified, "%Y-%m-%d %H:%M:%S.%f")
141+ fmt = "%Y-%m-%d %H:%M:%S"
142+ if "." in strified:
143+ fmt += ".%f"
144+ return datetime.strptime(strified, fmt)
145
146
147 class CommitDatabase(object):
148@@ -1002,11 +1005,11 @@
149 def is_marked(self, version, suite):
150 with Cursor(self.conn) as c:
151 rows = list(c.execute(self.REVID_TABLE_FIND % self.REVID_TABLE,
152- (str(version), self.package, suite)))
153+ (unicode(version), self.package, suite)))
154 rows += list(c.execute(self.REVID_TABLE_FIND % self.REVID_WORKING_TABLE,
155- (str(version), self.package, suite)))
156+ (unicode(version), self.package, suite)))
157 rows += [foo for foo in self.outstanding_marks
158- if foo == (str(version), suite)]
159+ if foo == (unicode(version), suite)]
160 assert len(rows) < 2, "Multiple versions for package/suite?"
161 if len(rows) > 0:
162 return True
163@@ -1020,7 +1023,7 @@
164 versions += [a[0] for a in c.execute(self.REVID_TABLE_FIND_SUITE
165 % self.REVID_TABLE,
166 (self.package, suite))]
167- versions += [str(foo[0]) for foo in self.outstanding_marks
168+ versions += [unicode(foo[0]) for foo in self.outstanding_marks
169 if foo[1] == suite]
170 if len(versions) > 0:
171 versions.sort(key=lambda x: changelog.Version(x))
172@@ -1031,11 +1034,11 @@
173 sha = self.get_testament_sha1(branch.repository, revid)
174 with Cursor(self.conn) as c:
175 rows = list(c.execute(self.REVID_TABLE_FIND % self.REVID_TABLE,
176- (str(version), self.package, suite)))
177+ (unicode(version), self.package, suite)))
178 rows += list(c.execute(self.REVID_TABLE_FIND % self.REVID_WORKING_TABLE,
179- (str(version), self.package, suite)))
180+ (unicode(version), self.package, suite)))
181 if (version, suite) in self.outstanding_marks:
182- revid, tment = self.outstanding_marks[(str(version), suite)]
183+ revid, tment = self.outstanding_marks[(unicode(version), suite)]
184 rows += (None, None, None, revid, tment)
185 if len(rows) < 1:
186 return False
187@@ -1043,9 +1046,9 @@
188 row = rows[0]
189 if (revid, sha) != (row[3], row[4]):
190 assert False, ("%s != %s for %s %s in %s, something has changed"
191- % (str((revid, sha)), str((row['revid'],
192+ % (unicode((revid, sha)), unicode((row['revid'],
193 row['testament'])), self.package,
194- str(version), suite))
195+ unicode(version), suite))
196 return True
197
198 def get_testament_sha1(self, repo, revid):
199@@ -1091,20 +1094,20 @@
200
201 def mark(self, version, revid, suite, branch):
202 sha = self.get_testament_sha1(branch.repository, revid)
203- self.outstanding_marks[(str(version), suite)] = (revid, sha)
204+ self.outstanding_marks[(unicode(version), suite)] = (revid, sha)
205
206 def commit_outstanding(self):
207 with Cursor(self.conn) as c:
208 for version, suite in self.outstanding_marks:
209 revid, sha = self.outstanding_marks[(version, suite)]
210 rows = list(c.execute(self.REVID_TABLE_FIND % self.REVID_TABLE,
211- (str(version), self.package, suite)))
212+ (unicode(version), self.package, suite)))
213 rows += list(c.execute(self.REVID_TABLE_FIND % self.REVID_WORKING_TABLE,
214- (str(version), self.package, suite)))
215+ (unicode(version), self.package, suite)))
216 assert len(rows) < 1, "Trying to mark version %s in %s again" \
217- % (str(version), suite)
218+ % (unicode(version), suite)
219 c.execute(self.REVID_TABLE_INSERT % self.REVID_WORKING_TABLE,
220- (self.package, str(version), suite, revid, sha))
221+ (self.package, unicode(version), suite, revid, sha))
222 self.outstanding_marks = {}
223
224 def get_suffix(self):
225@@ -1151,7 +1154,7 @@
226 with Cursor(self.conn) as c:
227 rows = c.execute("select * from %s"
228 % table)
229- return [(r[0], r[1], r[2]) for r in rows]
230+ return [(make_datetime(r[0]), r[1], r[2]) for r in rows]
231
232 def get_main_counts(self):
233 return self._get_counts(self.MAIN_FAILED_TABLE)
234@@ -1168,7 +1171,7 @@
235
236 def is_marked(self, version, suite):
237 revid_map = self._get_map(suite)
238- return str(version) in revid_map
239+ return unicode(version) in revid_map
240
241 def last_marked_version(self, suite):
242 revid_map = self._get_map(suite)
243@@ -1180,13 +1183,13 @@
244
245 def check(self, version, revid, suite, branch):
246 revid_map = self._get_map(suite)
247- if not str(version) in revid_map:
248+ if not unicode(version) in revid_map:
249 return False
250 sha = self.get_testament_sha1(branch.repository, revid)
251- if (revid, sha) != revid_map[str(version)]:
252+ if (revid, sha) != revid_map[unicode(version)]:
253 mutter("%s != %s for %s %s, something has changed"
254- % (str((revid, sha)), str(revid_map[str(version)]),
255- self.package, str(version)))
256+ % (unicode((revid, sha)), unicode(revid_map[unicode(version)]),
257+ self.package, unicode(version)))
258 return False
259 return True
260
261@@ -1208,11 +1211,11 @@
262
263 def mark(self, version, revid, suite, branch):
264 revid_map = self._get_map(suite)
265- assert str(version) not in revid_map, \
266+ assert unicode(version) not in revid_map, \
267 "Asked to mark %s %s %s, but it is already marked" \
268 % (self.package, version, suite)
269 sha = self.get_testament_sha1(branch.repository, revid)
270- revid_map[str(version)] = (revid, sha)
271+ revid_map[unicode(version)] = (revid, sha)
272 self._save_map(suite, revid_map)
273
274 def commit_outstanding(self):
275@@ -1494,8 +1497,8 @@
276 debian_b = branch.Branch.open(os.path.join(temp_dir,
277 default_debian_diff_release))
278 except errors.NotBranchError:
279- debian_b = bstore.get_branch_parts("debian",
280- default_debian_diff_release, "release",
281+ debian_b = bstore.get_branch_parts(u"debian",
282+ default_debian_diff_release, u"release",
283 possible_transports=possible_transports)
284 if debian_b is None:
285 # Not in unstable
286@@ -1507,8 +1510,8 @@
287 ubuntu_current_series))
288 ubuntu_tree = ubuntu_b.bzrdir.open_workingtree()
289 except errors.NotBranchError:
290- ubuntu_b = bstore.get_branch_parts("ubuntu", ubuntu_current_series,
291- "release", possible_transports=possible_transports)
292+ ubuntu_b = bstore.get_branch_parts(u"ubuntu", ubuntu_current_series,
293+ u"release", possible_transports=possible_transports)
294 if ubuntu_b is not None and ensure_ubuntu_local:
295 to_transport = transport.get_transport(os.path.join(temp_dir,
296 ubuntu_current_series))
297
298=== modified file 'udd/scripts/import_package.py'
299--- udd/scripts/import_package.py 2012-03-23 16:56:38 +0000
300+++ udd/scripts/import_package.py 2012-04-04 17:35:29 +0000
301@@ -52,18 +52,18 @@
302
303 push_lock = threading.Lock()
304
305-distros = ("debian", "ubuntu",)
306-
307-distro_list_base = {"ubuntu": "http://archive.ubuntu.com/ubuntu/dists/",
308- "debian": "http://ftp.debian.org/dists/",
309-}
310-
311-distro_components = {"ubuntu": ["main", "restricted", "universe", "multiverse"],
312- "debian": ["main", "contrib", "non-free"],
313-}
314-
315-distro_pool = {"ubuntu": "http://archive.ubuntu.com/ubuntu/",
316- "debian": "http://ftp.debian.org/",
317+distros = (u"debian", u"ubuntu",)
318+
319+distro_list_base = {u"ubuntu": "http://archive.ubuntu.com/ubuntu/dists/",
320+ u"debian": "http://ftp.debian.org/dists/",
321+}
322+
323+distro_components = {u"ubuntu": [u"main", u"restricted", u"universe", u"multiverse"],
324+ u"debian": [u"main", u"contrib", u"non-free"],
325+}
326+
327+distro_pool = {u"ubuntu": "http://archive.ubuntu.com/ubuntu/",
328+ u"debian": "http://ftp.debian.org/",
329 }
330
331 launchpad_base_url = "https://launchpad.net/"
332@@ -141,8 +141,8 @@
333 if icommon.lock_path(conf.get('pi.script_locks_dir'),
334 'update_lists') is None:
335 return
336- for release in ("woody", "sarge", "etch",):
337- for component in ("main", "contrib", "non-free"):
338+ for release in (u"woody", u"sarge", u"etch",):
339+ for component in (u"main", u"contrib", u"non-free"):
340 source_url = ''.join(['http://archive.debian.org/debian/dists/',
341 release, '/', component, '/source/Sources.gz'])
342 icommon.update_list(release, component, source_url)
343@@ -160,12 +160,12 @@
344 # - let's not.
345 distro_series_link = publication.lp_get_parameter('distro_series_link')
346 # eg u'https://api.launchpad.net/1.0/debian/sid'
347- return distro_series_link.rsplit('/', 2)[-1].lower()
348+ return unicode(distro_series_link.rsplit('/', 2)[-1].lower())
349
350
351 def get_debian_versions(lp, package, extra_debian=None):
352 vlist = icommon.ImportList()
353- d_archive = lp._udd_distributions['debian'].main_archive
354+ d_archive = lp._udd_distributions[u'debian'].main_archive
355 publications = lpapi.lp_call(lpapi.call_with_limited_size,
356 d_archive.getPublishedSources,
357 source_name=package, exact_match=True)
358@@ -177,7 +177,7 @@
359 release = release_name_from_publication(publication)
360 pocket = publication.pocket.lower()
361 version = changelog.Version(publication.source_package_version)
362- newp = icommon.PackageToImport(package, version, "debian", release,
363+ newp = icommon.PackageToImport(package, version, u"debian", release,
364 pocket)
365 vlist.add_if_needed(newp)
366 # if idx >= 20:
367@@ -207,13 +207,13 @@
368 line = line[line.index("|")+1:].strip()
369 release_component = line[:line.index("|")].strip()
370 if "/" in release_component:
371- release = release_component[:release_component.index("/")]
372- component = release_component[release_component.index("/")+1:]
373+ release = unicode(release_component[:release_component.index("/")])
374+ component = unicode(release_component[release_component.index("/")+1:])
375 else:
376- release = release_component
377- component = "main"
378- newp = icommon.PackageToImport(package, version, "debian", release,
379- "release", component=component, on_lp=False)
380+ release = unicode(release_component)
381+ component = u"main"
382+ newp = icommon.PackageToImport(package, version, u"debian", release,
383+ u"release", component=component, on_lp=False)
384 vlist.add_if_needed(newp)
385 if extra_debian is not None:
386 f = open(extra_debian)
387@@ -221,11 +221,11 @@
388 for line in f:
389 parts = line.split()
390 version = changelog.Version(parts[0])
391- release = parts[1]
392- pocket = parts[2]
393+ release = unicode(parts[1])
394+ pocket = unicode(parts[2])
395 base_url = parts[3]
396 url = os.path.join(os.path.dirname(extra_debian), base_url)
397- newp = icommon.PackageToImport(package, version, "debian",
398+ newp = icommon.PackageToImport(package, version, u"debian",
399 release, pocket, url=url)
400 vlist.add_if_needed(newp)
401 finally:
402@@ -235,7 +235,7 @@
403
404 def get_versions(lp, package, extra_debian=None):
405 vlist = get_debian_versions(lp, package, extra_debian=extra_debian)
406- u_archive = lp._udd_distributions['ubuntu'].main_archive
407+ u_archive = lp._udd_distributions[u'ubuntu'].main_archive
408 publications = lpapi.lp_call(lpapi.call_with_limited_size,
409 u_archive.getPublishedSources,
410 source_name=package, exact_match=True)
411@@ -248,7 +248,7 @@
412 release = release_name_from_publication(publication)
413 pocket = publication.pocket.lower()
414 version = changelog.Version(publication.source_package_version)
415- newp = icommon.PackageToImport(package, version, "ubuntu", release,
416+ newp = icommon.PackageToImport(package, version, u"ubuntu", release,
417 pocket)
418 vlist.add_if_needed(newp)
419 # if idx >= 20:
420@@ -305,11 +305,11 @@
421
422
423 def other_distro(distro):
424- assert distro in ("debian", "ubuntu")
425- if distro == "debian":
426- return "ubuntu"
427+ assert distro in (u"debian", u"ubuntu")
428+ if distro == u"debian":
429+ return u"ubuntu"
430 else:
431- return "debian"
432+ return u"debian"
433
434
435 def grab_file(base_url, name, target_dir, possible_transports=None):
436@@ -1170,7 +1170,7 @@
437 sys.exit(1)
438 try:
439 sys.exit(_import_package(
440- lp, args[0], push=not options.no_push,
441+ lp, unicode(args[0]), push=not options.no_push,
442 extra_debian=options.extra_debian, check=options.check,
443 no_existing=options.no_existing,
444 keep_temp=options.keep_temp,
445
446=== modified file 'udd/scripts/requeue_package.py'
447--- udd/scripts/requeue_package.py 2012-03-23 16:56:38 +0000
448+++ udd/scripts/requeue_package.py 2012-04-04 17:35:29 +0000
449@@ -44,6 +44,7 @@
450 db = icommon.StatusDatabase(conn, db_type)
451
452 for package in args:
453+ pacakge = unicode(package)
454 lock = icommon.lock_path(conf.get('pi.locks_dir'), package)
455 if lock is None:
456 print "Can't lock %s" % package
457
458=== modified file 'udd/scripts/show_failure.py'
459--- udd/scripts/show_failure.py 2012-03-23 16:56:38 +0000
460+++ udd/scripts/show_failure.py 2012-04-04 17:35:29 +0000
461@@ -19,4 +19,4 @@
462
463
464 def main():
465- sys.exit(print_reason(sys.argv[1]))
466+ sys.exit(print_reason(unicode(sys.argv[1])))
467
468=== added file 'udd/tests/test_history_database.py'
469--- udd/tests/test_history_database.py 1970-01-01 00:00:00 +0000
470+++ udd/tests/test_history_database.py 2012-04-04 17:35:29 +0000
471@@ -0,0 +1,33 @@
472+from datetime import datetime
473+
474+from bzrlib import tests
475+
476+from udd import icommon, idb
477+
478+
479+class TestHistoryDb(tests.TestCase):
480+
481+ def setUp(self):
482+ super(TestHistoryDb, self).setUp()
483+ self.db = icommon.HistoryDatabase(*idb.get_memory_db_connection())
484+
485+
486+class GetMainCountsTests(TestHistoryDb):
487+
488+ def test_returns_queued(self):
489+ self.db.set_main_counts(2, 3)
490+ counts = self.db.get_main_counts()
491+ self.assertEqual(1, len(counts))
492+ self.assertEqual(2, counts[0][1])
493+
494+ def test_returns_failed(self):
495+ self.db.set_main_counts(2, 3)
496+ counts = self.db.get_main_counts()
497+ self.assertEqual(1, len(counts))
498+ self.assertEqual(3, counts[0][2])
499+
500+ def test_returns_datetimes(self):
501+ self.db.set_main_counts(1, 2)
502+ counts = self.db.get_main_counts()
503+ self.assertEqual(1, len(counts))
504+ self.assertIsInstance(counts[0][0], datetime)
505
506=== modified file 'udd/tests/test_status_database.py'
507--- udd/tests/test_status_database.py 2012-03-23 16:56:38 +0000
508+++ udd/tests/test_status_database.py 2012-04-04 17:35:29 +0000
509@@ -99,6 +99,15 @@
510 self.db.add_import_jobs(['foo'], now)
511 self.assertEqual(now, self.db.last_import_time())
512
513+ def test_last_import_time_sqlite(self):
514+ # if the last import time was inserted by sqlite3 then it has a
515+ # different format from the one that storm would insert. Check
516+ # that the migration is handled ok.
517+ now = datetime.datetime.utcnow()
518+ self.db.conn.execute('INSERT into %s values (?)' % self.db.IMPORT_TABLE,
519+ (now.strftime("%Y-%m-%d %H:%M:%S"),))
520+ self.assertEqual(now.replace(microsecond=0), self.db.last_import_time())
521+
522
523 class TestRetry(TestStatusDb):
524

Subscribers

People subscribed via source and target branches