Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2707)

Unified Diff: chrome/test/data/autofill/merge/tools/serialize_profiles.py

Issue 6312174: Add a data-driven unit test to validate autofill profile merging during aggregation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename reserialization script Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/autofill/merge/tools/reserialize_profiles_from_query.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/autofill/merge/tools/serialize_profiles.py
diff --git a/chrome/test/data/autofill/merge/tools/serialize_profiles.py b/chrome/test/data/autofill/merge/tools/serialize_profiles.py
new file mode 100644
index 0000000000000000000000000000000000000000..94d4d95c8915b870178814c4b323152a55bbc894
--- /dev/null
+++ b/chrome/test/data/autofill/merge/tools/serialize_profiles.py
@@ -0,0 +1,41 @@
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os.path
+import sqlite3
+import sys
+
+from autofill_merge_common import SerializeProfiles, ColumnNameToFieldType
+
+def main():
+ """Serializes the autofill_profiles table from the specified database."""
+
+ if len(sys.argv) != 2:
+ print "Usage: python serialize_profiles.py <path/to/database>"
+ return
+
+ database = sys.argv[1]
+ if not os.path.isfile(database):
+ print "Cannot read database at \"%s\"" % database
+ return
+
+ try:
+ connection = sqlite3.connect(database, 0)
+ cursor = connection.cursor()
+ cursor.execute("SELECT * from autofill_profiles;")
+ except sqlite3.OperationalError:
+ print "Failed to read the autofill_profiles table from \"%s\"" % database
+ raise
+
+ # For backward-compatibility, the result of |cursor.description| is a list of
+ # 7-tuples, in which the first item is the column name, and the remaining
+ # items are 'None'.
+ types = [ColumnNameToFieldType(item[0]) for item in cursor.description]
+ profiles = [zip(types, profile) for profile in cursor]
+
+ print SerializeProfiles(profiles)
+
+
+if __name__ == '__main__':
+ main()
« no previous file with comments | « chrome/test/data/autofill/merge/tools/reserialize_profiles_from_query.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698