Chromium Code Reviews| 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.
|