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

Unified Diff: tools/telemetry/third_party/gsutilz/third_party/protorpc/demos/tunes_db/server/model_test.py

Issue 1264873003: Add gsutil/third_party to telemetry/third_party/gsutilz/third_party. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove httplib2 Created 5 years, 5 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: tools/telemetry/third_party/gsutilz/third_party/protorpc/demos/tunes_db/server/model_test.py
diff --git a/tools/telemetry/third_party/gsutilz/third_party/protorpc/demos/tunes_db/server/model_test.py b/tools/telemetry/third_party/gsutilz/third_party/protorpc/demos/tunes_db/server/model_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..d8a0cd77756c720beeaaee51c5a8209836196a52
--- /dev/null
+++ b/tools/telemetry/third_party/gsutilz/third_party/protorpc/demos/tunes_db/server/model_test.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+#
+# Copyright 2010 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""Tests for model."""
+
+__author__ = 'rafek@google.com (Rafe Kaplan)'
+
+import unittest
+
+from google.appengine.ext import db
+
+import datastore_test_util
+import model
+
+
+class InfoTest(datastore_test_util.DatastoreTest):
+ """Test the info base class.
+
+ This test uses the ArtistInfo sub-class, but the functionality defined
+ there will work for all sub-classes.
+ """
+
+ def testEncodedName(self):
+ """Test the encoded_name derived property."""
+
+ def get_encoded_name(name):
+ """Helper to get encoded name for an provided name.
+
+ Args:
+ name: Encoded name to convert to encoded_name.
+ """
+ return db.get(model.ArtistInfo(name=name).put()).encoded_name
+
+ # Normal strings.
+ self.assertEquals('stereo total', get_encoded_name('Stereo Total'))
+ # Not alphabetic characters.
+ self.assertEquals('the go team', get_encoded_name('The Go! Team'))
+ # Unecessary spaces.
+ self.assertEquals('ananda shankar',
+ get_encoded_name(' Ananda Shankar '))
+ # Non-ascii unicode.
+ self.assertEquals('vive la f\xc3\xaate',
+ get_encoded_name(u'Vive la f\xeate'))
+ # Numerics.
+ self.assertEquals('delta5', get_encoded_name(u'Delta5'))
+
+ # The pesky '_'.
+ self.assertEquals('wendy carlos', get_encoded_name('Wendy__Carlos'))
+
+ def testSearch(self):
+ """Test searching by name prefix."""
+ # Defined out of order to make sure search is in order.
+ model.ArtistInfo(name='The Bee__Gees').put()
+ model.ArtistInfo(name=' The-DooRs ').put()
+ model.ArtistInfo(name='Wendy Carlos').put()
+ model.ArtistInfo(name='Amadeus Mozart').put()
+ model.ArtistInfo(name='The Beatles').put()
+
+ names = [artist.name for artist in model.ArtistInfo.search(' ')]
+ self.assertEquals(['Amadeus Mozart', 'The Beatles', 'The Bee__Gees',
+ ' The-DooRs ', 'Wendy Carlos'],
+ names)
+
+ names = [artist.name for artist in model.ArtistInfo.search(' !tHe} ')]
+ self.assertEquals(['The Beatles', 'The Bee__Gees', ' The-DooRs '], names)
+
+ names = [artist.name for artist in model.ArtistInfo.search('the bee gees')]
+ self.assertEquals(['The Bee__Gees'], names)
+
+ names = [artist.name for artist in model.ArtistInfo.search('the doors')]
+ self.assertEquals([' The-DooRs '], names)
+
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698