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

Side by Side Diff: Tools/TestResultServer/model/datastorefile_test.py

Issue 298163003: Fix crash in the flakiness dashboard server. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Tools/TestResultServer/model/datastorefile.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 self.assertTrue(self.test_file.save_data(test_data)) 51 self.assertTrue(self.test_file.save_data(test_data))
52 self.assertEqual(test_data, self.test_file.data) 52 self.assertEqual(test_data, self.test_file.data)
53 53
54 self.assertEqual(test_data, self.test_file.load_data()) 54 self.assertEqual(test_data, self.test_file.load_data())
55 self.assertEqual(test_data, self.test_file.data) 55 self.assertEqual(test_data, self.test_file.data)
56 56
57 self.test_file.delete_data() 57 self.test_file.delete_data()
58 self.assertFalse(self.test_file.load_data()) 58 self.assertFalse(self.test_file.load_data())
59 59
60 def testLoadDataInvalidKey(self):
61 test_data = 'x' * datastorefile.MAX_ENTRY_LEN * 3
62
63 self.assertTrue(self.test_file.save_data(test_data))
64 self.assertEqual(test_data, self.test_file.data)
65
66 self.test_file.delete_data()
67 self.assertEqual('', self.test_file.load_data())
68
69 def testLoadDataNoKeys(self):
70 # This should never happen.
71 self.assertEqual(None, self.test_file.load_data())
72
60 def testSaveData(self): 73 def testSaveData(self):
61 self.assertFalse(self.test_file.save_data(None)) 74 self.assertFalse(self.test_file.save_data(None))
62 75
63 too_big_data = 'x' * (datastorefile.MAX_DATA_ENTRY_PER_FILE * datastoref ile.MAX_ENTRY_LEN + 1) 76 too_big_data = 'x' * (datastorefile.MAX_DATA_ENTRY_PER_FILE * datastoref ile.MAX_ENTRY_LEN + 1)
64 self.assertFalse(self.test_file.save_data(too_big_data)) 77 self.assertFalse(self.test_file.save_data(too_big_data))
65 78
66 test_data = 'x' * datastorefile.MAX_ENTRY_LEN * 5 79 test_data = 'x' * datastorefile.MAX_ENTRY_LEN * 5
67 self.assertTrue(self.test_file.save_data(test_data)) 80 self.assertTrue(self.test_file.save_data(test_data))
68 nchunks = datastorefile.DataEntry.all().count() 81 nchunks = datastorefile.DataEntry.all().count()
69 nkeys = len(self.test_file.data_keys) + len(self.test_file.new_data_keys ) 82 nkeys = len(self.test_file.data_keys) + len(self.test_file.new_data_keys )
(...skipping 24 matching lines...) Expand all
94 self.assertEqual(len(chunk_indices), 3) 107 self.assertEqual(len(chunk_indices), 3)
95 self.assertNotEqual(chunk_indices[0], chunk_indices[-1]) 108 self.assertNotEqual(chunk_indices[0], chunk_indices[-1])
96 109
97 data_length += 1 110 data_length += 1
98 chunk_indices = self.test_file._get_chunk_indices(data_length) 111 chunk_indices = self.test_file._get_chunk_indices(data_length)
99 self.assertEqual(len(chunk_indices), 4) 112 self.assertEqual(len(chunk_indices), 4)
100 113
101 114
102 if __name__ == '__main__': 115 if __name__ == '__main__':
103 unittest.main() 116 unittest.main()
OLDNEW
« no previous file with comments | « Tools/TestResultServer/model/datastorefile.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698