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

Unified Diff: chrome/test/data/autofill/merge/tools/autofill_merge_common.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
Index: chrome/test/data/autofill/merge/tools/autofill_merge_common.py
diff --git a/chrome/test/data/autofill/merge/tools/autofill_merge_common.py b/chrome/test/data/autofill/merge/tools/autofill_merge_common.py
new file mode 100644
index 0000000000000000000000000000000000000000..be4d058fda10119f4d26fcff1ce93ba5c433c629
--- /dev/null
+++ b/chrome/test/data/autofill/merge/tools/autofill_merge_common.py
@@ -0,0 +1,75 @@
+# 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.
+
+
+class UnknownColumnNameException(Exception):
+ """Exception type raised when encountering an unknown column name."""
+ def __init__(self, column_name):
+ self.column_name = column_name
+ def __str__(self):
+ return repr(self.column_name)
+
+
+def SerializeProfiles(profiles):
+ """Returns a serialized string for the given |profiles|.
+
+ |profiles| should be a list of (field_type, value) string pairs.
+
+ """
+
+ lines = []
+ for profile in profiles:
+ # Include a fixed string to separate profiles.
+ lines.append("---")
+ for (field_type, value) in profile:
+ if field_type == "ignored":
+ continue;
+
+ lines.append("%s: %s" % (field_type, value))
+
+ return '\n'.join(lines)
+
+
+def ColumnNameToFieldType(column_name):
+ """Converts the given |column_name| to the corresponding AutoFillField type.
+
+ |column_name| should be a string drawn from the column names of the
+ autofill_profiles table in the Chromium "Web Data" database.
+
+ """
+
+ column_name = column_name.lower()
+ field_type = "unknown"
+ if column_name in ["guid", "label", "date_modified"]:
+ field_type = "ignored"
+ elif column_name == "first_name":
+ field_type = "NAME_FIRST"
+ elif column_name == "middle_name":
+ field_type = "NAME_MIDDLE"
+ elif column_name == "last_name":
+ field_type = "NAME_LAST"
+ elif column_name == "email":
+ field_type = "EMAIL_ADDRESS"
+ elif column_name == "company_name":
+ field_type = "COMPANY_NAME"
+ elif column_name == "address_line_1":
+ field_type = "ADDRESS_HOME_LINE1"
+ elif column_name == "address_line_2":
+ field_type = "ADDRESS_HOME_LINE2"
+ elif column_name == "city":
+ field_type = "ADDRESS_HOME_CITY"
+ elif column_name == "state":
+ field_type = "ADDRESS_HOME_STATE"
+ elif column_name == "zipcode":
+ field_type = "ADDRESS_HOME_ZIP"
+ elif column_name == "country":
+ field_type = "ADDRESS_HOME_COUNTRY"
+ elif column_name == "phone":
+ field_type = "PHONE_HOME_WHOLE_NUMBER"
+ elif column_name == "fax":
+ field_type = "PHONE_FAX_WHOLE_NUMBER"
+ else:
+ raise UnknownColumnNameException(column_name)
+
+ return field_type
« no previous file with comments | « chrome/test/data/autofill/merge/output/identical.out ('k') | chrome/test/data/autofill/merge/tools/flatten.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698