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

Side by Side Diff: appengine/swarming/handlers_endpoints_test.py

Issue 2249803003: Create Tasks.Tags endpoint and Cron job (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Docs Created 4 years, 4 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
« no previous file with comments | « appengine/swarming/handlers_endpoints.py ('k') | appengine/swarming/handlers_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding=utf-8 2 # coding=utf-8
3 # Copyright 2015 The LUCI Authors. All rights reserved. 3 # Copyright 2015 The LUCI Authors. All rights reserved.
4 # Use of this source code is governed under the Apache License, Version 2.0 4 # Use of this source code is governed under the Apache License, Version 2.0
5 # that can be found in the LICENSE file. 5 # that can be found in the LICENSE file.
6 6
7 import base64 7 import base64
8 import datetime 8 import datetime
9 import json 9 import json
10 import logging 10 import logging
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 except: # pylint: disable=bare-except 851 except: # pylint: disable=bare-except
852 self.fail( 852 self.fail(
853 'Is unsupported: (%s, %s, %s)' % 853 'Is unsupported: (%s, %s, %s)' %
854 (using_filter, state, sort)) 854 (using_filter, state, sort))
855 # Don't check for correctness here, just assert that it doesn't 855 # Don't check for correctness here, just assert that it doesn't
856 # throw due to missing index or invalid query. 856 # throw due to missing index or invalid query.
857 result.pop(u'items', None) 857 result.pop(u'items', None)
858 expected = {u'now': str_now_120} 858 expected = {u'now': str_now_120}
859 self.assertEqual(expected, result) 859 self.assertEqual(expected, result)
860 860
861 def test_tags_ok(self):
862 """Asserts that TasksTags is returned with the right data."""
863 self.set_as_privileged_user()
864 now = datetime.datetime(2009, 1, 2, 3, 4, 5, 6)
865 self.mock_now(now)
866 task_result.TagAggregation(
867 key=task_result.TagAggregation.KEY,
868 tags=[
869 task_result.TagValues(
870 tag='foo', values=['alpha', 'beta']),
871 task_result.TagValues(
872 tag='bar', values=['gamma', 'delta', 'epsilon']),
873 ],
874 ts=now).put()
875 expected = {
876 u'tasks_tags': [
877 {
878 u'key': 'foo',
879 u'value': [u'alpha', u'beta'],
880 },
881 {
882 u'key': 'bar',
883 u'value': [u'gamma', u'delta', u'epsilon'],
884 },
885 ],
886 u'ts': unicode(now.strftime(self.DATETIME_FORMAT)),
887 }
888 self.assertEqual(expected, self.call_api('tags', body={}).json)
889
861 def _gen_two_tasks(self): 890 def _gen_two_tasks(self):
862 # first request 891 # first request
863 now = datetime.datetime(2010, 1, 2, 3, 4, 5) 892 now = datetime.datetime(2010, 1, 2, 3, 4, 5)
864 str_now = unicode(now.strftime(self.DATETIME_NO_MICRO)) 893 str_now = unicode(now.strftime(self.DATETIME_NO_MICRO))
865 self.mock_now(now) 894 self.mock_now(now)
866 self.mock(random, 'getrandbits', lambda _: 0x66) 895 self.mock(random, 'getrandbits', lambda _: 0x66)
867 _, first_id = self.client_create_task_raw( 896 _, first_id = self.client_create_task_raw(
868 name='first', tags=['project:yay', 'commit:post', 'os:Win'], 897 name='first', tags=['project:yay', 'commit:post', 'os:Win'],
869 properties=dict(idempotent=True)) 898 properties=dict(idempotent=True))
870 self.set_as_bot() 899 self.set_as_bot()
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 self.assertEqual(expected, response.json) 1917 self.assertEqual(expected, response.json)
1889 1918
1890 1919
1891 if __name__ == '__main__': 1920 if __name__ == '__main__':
1892 if '-v' in sys.argv: 1921 if '-v' in sys.argv:
1893 unittest.TestCase.maxDiff = None 1922 unittest.TestCase.maxDiff = None
1894 logging.basicConfig(level=logging.DEBUG) 1923 logging.basicConfig(level=logging.DEBUG)
1895 else: 1924 else:
1896 logging.basicConfig(level=logging.CRITICAL) 1925 logging.basicConfig(level=logging.CRITICAL)
1897 unittest.main() 1926 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_endpoints.py ('k') | appengine/swarming/handlers_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698