Chromium Code Reviews| Index: dashboard/dashboard/create_health_report_test.py |
| diff --git a/dashboard/dashboard/create_health_report_test.py b/dashboard/dashboard/create_health_report_test.py |
| index f3aadac29b48403e290b7586c25796b70816f871..6cc4ac148032dce4b2fdbcf2defb0f7cea29cdf0 100644 |
| --- a/dashboard/dashboard/create_health_report_test.py |
| +++ b/dashboard/dashboard/create_health_report_test.py |
| @@ -20,8 +20,9 @@ _SAMPLE_TABLE_CONFIG = { |
| 'tableName': 'my_sample_config', |
| 'tableBots': 'ChromiumPerf/win\nChromiumPerf/linux', |
| 'tableTests': 'my_test_suite/my_test\nmy_test_suite/my_other_test', |
| - 'tableLayout': '{ "system_health.memory_mobile/foreground/ashmem":' |
| - '["Foreground", "Ashmem"]}', |
| + 'tableLayout': '{"my_test_suite/my_test": ["Foreground", ' |
| + '"Pretty Name 1"], "my_test_suite/my_other_test": ' |
| + '["Foreground", "Pretty Name 2"]}', |
| } |
| class CreateHealthReportTest(testing_common.TestCase): |
| @@ -48,6 +49,13 @@ class CreateHealthReportTest(testing_common.TestCase): |
| graph_data.Bot( |
| id='linux', parent=master_key, internal_only=True).put() |
| + self._AddTests() # This function seems to break the internal_only of the |
|
eakuefner
2017/01/28 00:22:17
Yikes, this is scary. Can we figure out what's goi
jessimb
2017/01/30 19:23:10
Ah! I thought I had looked into this but with fres
|
| + # bots, so the below fixes it. |
| + bots = graph_data.Bot.query().fetch() |
| + for bot in bots: |
| + bot.internal_only = True |
| + bot.put() |
| + |
| def _AddMixedBotsToDataStore(self): |
| """Adds sample bot/master pairs.""" |
| master_key = ndb.Key('Master', 'ChromiumPerf') |
| @@ -56,6 +64,12 @@ class CreateHealthReportTest(testing_common.TestCase): |
| graph_data.Bot( |
| id='linux', parent=master_key, internal_only=True).put() |
| + self._AddTests()# This function seems to break the internal_only of the |
| + # bots, so the below fixes it for linux only. |
| + bots = graph_data.Bot.query().fetch() |
| + bots[1].internal_only = True |
| + bots[1].put() |
| + |
| def _AddPublicBotsToDataStore(self): |
| """Adds sample bot/master pairs.""" |
| master_key = ndb.Key('Master', 'ChromiumPerf') |
| @@ -63,6 +77,15 @@ class CreateHealthReportTest(testing_common.TestCase): |
| id='win', parent=master_key, internal_only=False).put() |
| graph_data.Bot( |
| id='linux', parent=master_key, internal_only=False).put() |
| + self._AddTests() |
| + |
| + def _AddTests(self): |
| + testing_common.AddTests(['ChromiumPerf'], ['win', 'linux'], { |
| + 'my_test_suite': { |
| + 'my_test': {}, |
| + 'my_other_test': {}, |
| + } |
| + }) |
| def testPost_NoXSRFToken_Returns403Error(self): |
| self.testapp.post('/create_health_report', { |
| @@ -107,8 +130,9 @@ class CreateHealthReportTest(testing_common.TestCase): |
| bots = [win_bot, linux_bot] |
| self.assertEqual(bots, table_entity.bots) |
| self.assertEqual( |
| - '{ "system_health.memory_mobile/foreground/ashmem":' |
| - '["Foreground", "Ashmem"]}', table_entity.table_layout) |
| + '{"my_test_suite/my_test": ["Foreground", "Pretty Name 1"], ' |
| + '"my_test_suite/my_other_test": ["Foreground", "Pretty Name 2"]}', |
| + table_entity.table_layout) |
| def testPost_EmptyForm(self): |
| response = self.testapp.post('/create_health_report', { |
| @@ -134,8 +158,8 @@ class CreateHealthReportTest(testing_common.TestCase): |
| response = self.testapp.post('/create_health_report', { |
| 'tableName': 'myName', |
| 'tableBots': 'garbage/moarGarbage', |
| - 'tableTests': 'someTests', |
| - 'tableLayout': '{A layout}', |
| + 'tableTests': 'my_test_suite/my_test', |
| + 'tableLayout': '{"Alayout":"isHere"}', |
| 'xsrf_token': xsrf.GenerateToken(users.get_current_user()), |
| }) |
| self.assertIn('Invalid Master/Bot: garbage/moarGarbage', response) |
| @@ -166,7 +190,7 @@ class CreateHealthReportTest(testing_common.TestCase): |
| response = self.testapp.post('/create_health_report', { |
| 'tableName': 'myName', |
| 'tableBots': 'ChromiumPerf/linux', |
| - 'tableTests': 'someTests', |
| + 'tableTests': 'my_test_suite/my_test', |
| 'tableLayout': 'garbage', |
| 'xsrf_token': xsrf.GenerateToken(users.get_current_user()), |
| }) |
| @@ -174,3 +198,19 @@ class CreateHealthReportTest(testing_common.TestCase): |
| query = table_config.TableConfig.query() |
| table_values = query.fetch() |
| self.assertEqual(len(table_values), 0) |
| + |
| + def testPost_InvalidTests(self): |
| + self._AddInternalBotsToDataStore() |
| + _SAMPLE_TABLE_CONFIG['xsrf_token'] = xsrf.GenerateToken( |
| + users.get_current_user()) |
| + response = self.testapp.post('/create_health_report', { |
| + 'tableName': 'myName', |
| + 'tableBots': 'ChromiumPerf/linux', |
| + 'tableTests': 'someTests', |
| + 'tableLayout': '{"Alayout":"isHere"}', |
| + 'xsrf_token': xsrf.GenerateToken(users.get_current_user()), |
| + }) |
| + self.assertIn('someTests is not a valid test.', response) |
| + query = table_config.TableConfig.query() |
| + table_values = query.fetch() |
| + self.assertEqual(len(table_values), 0) |