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

Unified Diff: tools/deep_memory_profiler/visualizer/app_unittest.py

Issue 23781012: Upload file to app engine and generate public url for dmprof visualizer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit test and separate business logic layer to services.py Created 7 years, 3 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/deep_memory_profiler/visualizer/app_unittest.py
diff --git a/tools/deep_memory_profiler/visualizer/app_unittest.py b/tools/deep_memory_profiler/visualizer/app_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..3097298d5bc349e139f4e5208a3336017a62da09
--- /dev/null
+++ b/tools/deep_memory_profiler/visualizer/app_unittest.py
@@ -0,0 +1,48 @@
+# Copyright 2013 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 services
+import unittest
+
+from google.appengine.api import files
+from google.appengine.ext import testbed
+from google.appengine.ext.blobstore import BlobInfo
+
+
+class ServicesTest(unittest.TestCase):
+ def setUp(self):
+ self.testbed = testbed.Testbed()
+ self.testbed.activate()
+ self.testbed.init_all_stubs()
+
+ # Read sample file.
+ self.json_str = open('testdata/sample.json', 'r').read()
+
+ # Create file in blobstore according to sample file.
+ file_name = files.blobstore.create(mime_type='text/plain')
+ with files.open(file_name, 'a') as f:
+ f.write(self.json_str)
+ files.finalize(file_name)
+
+ # Get BlobInfo of sample file.
+ self.blob_info = BlobInfo.get(files.blobstore.get_blob_key(file_name))
+
+ def tearDown(self):
+ self.testbed.deactivate()
+
+ def testProfiler(self):
+ # Call services function to create Profiler entity.
+ run_id = services.CreateProfiler(self.blob_info)
+
+ # Test GetProfiler
+ self.assertEqual(services.GetProfiler(run_id), self.json_str)
+
+ # Create Profiler entity with the same file again and check uniqueness.
+ services.CreateProfiler(self.blob_info)
+ self.assertEqual(services.Profiler.query().count(), 1)
+
+ def testTemplate(self):
+ # Call services function to create template entities.
+ services.CreateTemplates(self.blob_info)
+ self.assertEqual(services.Template.query().count(), 2)
sullivan 2013/09/20 13:59:51 Might want to do some testing of the content of th
junjianx 2013/09/24 05:53:53 Done.

Powered by Google App Engine
This is Rietveld 408576698