PageRenderTime 38ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/master/buildbot/test/unit/test_data_forceschedulers.py

https://gitlab.com/murder187ss/buildbot
Python | 166 lines | 149 code | 3 blank | 14 comment | 0 complexity | 3702ed56f31ea3a2982364be9d54f172 MD5 | raw file
  1. # This file is part of Buildbot. Buildbot is free software: you can
  2. # redistribute it and/or modify it under the terms of the GNU General Public
  3. # License as published by the Free Software Foundation, version 2.
  4. #
  5. # This program is distributed in the hope that it will be useful, but WITHOUT
  6. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  7. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  8. # details.
  9. #
  10. # You should have received a copy of the GNU General Public License along with
  11. # this program; if not, write to the Free Software Foundation, Inc., 51
  12. # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  13. #
  14. # Copyright Buildbot Team Members
  15. from twisted.internet import defer
  16. from twisted.trial import unittest
  17. from buildbot.data import forceschedulers
  18. from buildbot.schedulers.forcesched import ForceScheduler
  19. from buildbot.test.util import endpoint
  20. expected_default = {
  21. 'all_fields': [{'columns': 1,
  22. 'default': '',
  23. 'fields': [{'default': '',
  24. 'fullName': 'username',
  25. 'hide': False,
  26. 'label': 'Your name:',
  27. 'multiple': False,
  28. 'name': 'username',
  29. 'need_email': True,
  30. 'regex': None,
  31. 'required': False,
  32. 'size': 30,
  33. 'tablabel': 'Your name:',
  34. 'type': 'username'},
  35. {'default': 'force build',
  36. 'fullName': 'reason',
  37. 'hide': False,
  38. 'label': 'reason',
  39. 'multiple': False,
  40. 'name': 'reason',
  41. 'regex': None,
  42. 'required': False,
  43. 'size': 20,
  44. 'tablabel': 'reason',
  45. 'type': 'text'}],
  46. 'fullName': None,
  47. 'hide': False,
  48. 'label': '',
  49. 'layout': 'vertical',
  50. 'multiple': False,
  51. 'name': '',
  52. 'regex': None,
  53. 'required': False,
  54. 'tablabel': '',
  55. 'type': 'nested'},
  56. {'columns': 2,
  57. 'default': '',
  58. 'fields': [{'default': '',
  59. 'fullName': 'project',
  60. 'hide': False,
  61. 'label': 'Project:',
  62. 'multiple': False,
  63. 'name': 'project',
  64. 'regex': None,
  65. 'required': False,
  66. 'size': 10,
  67. 'tablabel': 'Project:',
  68. 'type': 'text'},
  69. {'default': '',
  70. 'fullName': 'repository',
  71. 'hide': False,
  72. 'label': 'Repository:',
  73. 'multiple': False,
  74. 'name': 'repository',
  75. 'regex': None,
  76. 'required': False,
  77. 'size': 10,
  78. 'tablabel': 'Repository:',
  79. 'type': 'text'},
  80. {'default': '',
  81. 'fullName': 'branch',
  82. 'hide': False,
  83. 'label': 'Branch:',
  84. 'multiple': False,
  85. 'name': 'branch',
  86. 'regex': None,
  87. 'required': False,
  88. 'size': 10,
  89. 'tablabel': 'Branch:',
  90. 'type': 'text'},
  91. {'default': '',
  92. 'fullName': 'revision',
  93. 'hide': False,
  94. 'label': 'Revision:',
  95. 'multiple': False,
  96. 'name': 'revision',
  97. 'regex': None,
  98. 'required': False,
  99. 'size': 10,
  100. 'tablabel': 'Revision:',
  101. 'type': 'text'}],
  102. 'fullName': None,
  103. 'hide': False,
  104. 'label': '',
  105. 'layout': 'vertical',
  106. 'multiple': False,
  107. 'name': '',
  108. 'regex': None,
  109. 'required': False,
  110. 'tablabel': '',
  111. 'type': 'nested'}],
  112. 'builder_names': [u'builder'],
  113. 'button_name': u'defaultforce',
  114. 'label': u'defaultforce',
  115. 'name': u'defaultforce'}
  116. class ForceschedulerEndpoint(endpoint.EndpointMixin, unittest.TestCase):
  117. endpointClass = forceschedulers.ForceSchedulerEndpoint
  118. resourceTypeClass = forceschedulers.ForceScheduler
  119. def setUp(self):
  120. self.setUpEndpoint()
  121. scheds = [ForceScheduler(
  122. name="defaultforce",
  123. builderNames=["builder"])]
  124. self.master.allSchedulers = lambda: scheds
  125. def tearDown(self):
  126. self.tearDownEndpoint()
  127. @defer.inlineCallbacks
  128. def test_get_existing(self):
  129. res = yield self.callGet(('forceschedulers', "defaultforce"))
  130. self.validateData(res)
  131. self.assertEquals(res, expected_default)
  132. @defer.inlineCallbacks
  133. def test_get_missing(self):
  134. res = yield self.callGet(('forceschedulers', 'foo'))
  135. self.assertEquals(res, None)
  136. class ForceSchedulersEndpoint(endpoint.EndpointMixin, unittest.TestCase):
  137. endpointClass = forceschedulers.ForceSchedulersEndpoint
  138. resourceTypeClass = forceschedulers.ForceScheduler
  139. def setUp(self):
  140. self.setUpEndpoint()
  141. scheds = [ForceScheduler(
  142. name="defaultforce",
  143. builderNames=["builder"])]
  144. self.master.allSchedulers = lambda: scheds
  145. def tearDown(self):
  146. self.tearDownEndpoint()
  147. @defer.inlineCallbacks
  148. def test_get_existing(self):
  149. res = yield self.callGet(('forceschedulers', ))
  150. self.assertEquals(res, [expected_default])