hammer_cli_foreman 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of hammer_cli_foreman might be problematic. Click here for more details.

Files changed (340) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -2
  3. data/doc/host_create.md +15 -7
  4. data/doc/release_notes.md +11 -0
  5. data/lib/hammer_cli_foreman/commands.rb +5 -1
  6. data/lib/hammer_cli_foreman/defaults.rb +29 -0
  7. data/lib/hammer_cli_foreman/host.rb +8 -1
  8. data/lib/hammer_cli_foreman/id_resolver.rb +1 -1
  9. data/lib/hammer_cli_foreman/location.rb +21 -0
  10. data/lib/hammer_cli_foreman/organization.rb +21 -0
  11. data/lib/hammer_cli_foreman/parameter.rb +7 -7
  12. data/lib/hammer_cli_foreman/role.rb +13 -0
  13. data/lib/hammer_cli_foreman/subnet.rb +1 -1
  14. data/lib/hammer_cli_foreman/version.rb +1 -1
  15. data/lib/hammer_cli_foreman.rb +2 -0
  16. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  17. data/locale/de/hammer-cli-foreman.edit.po +394 -423
  18. data/locale/de/hammer-cli-foreman.po +1920 -1511
  19. data/locale/en/hammer-cli-foreman.edit.po +188 -124
  20. data/locale/en/hammer-cli-foreman.po +49 -1
  21. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  22. data/locale/en_GB/hammer-cli-foreman.edit.po +208 -152
  23. data/locale/en_GB/hammer-cli-foreman.po +1554 -1145
  24. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  25. data/locale/es/hammer-cli-foreman.edit.po +438 -464
  26. data/locale/es/hammer-cli-foreman.po +1930 -1519
  27. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  28. data/locale/fr/hammer-cli-foreman.edit.po +301 -328
  29. data/locale/fr/hammer-cli-foreman.po +1922 -1513
  30. data/locale/hammer-cli-foreman.pot +194 -127
  31. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  32. data/locale/it/hammer-cli-foreman.edit.po +303 -331
  33. data/locale/it/hammer-cli-foreman.po +1909 -1500
  34. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/ja/hammer-cli-foreman.edit.po +302 -330
  36. data/locale/ja/hammer-cli-foreman.po +1920 -1511
  37. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/ko/hammer-cli-foreman.edit.po +303 -332
  39. data/locale/ko/hammer-cli-foreman.po +1910 -1501
  40. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  41. data/locale/pt_BR/hammer-cli-foreman.edit.po +369 -393
  42. data/locale/pt_BR/hammer-cli-foreman.po +1916 -1506
  43. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  44. data/locale/ru/hammer-cli-foreman.edit.po +344 -372
  45. data/locale/ru/hammer-cli-foreman.po +1940 -1531
  46. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  47. data/locale/zh_CN/hammer-cli-foreman.edit.po +303 -331
  48. data/locale/zh_CN/hammer-cli-foreman.po +1905 -1496
  49. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  50. data/locale/zh_TW/hammer-cli-foreman.edit.po +306 -334
  51. data/locale/zh_TW/hammer-cli-foreman.po +1908 -1499
  52. data/test/functional/api_expectations.rb +65 -0
  53. data/test/functional/command_assertions.rb +76 -0
  54. data/test/functional/location_test.rb +140 -0
  55. data/test/functional/organization_test.rb +140 -0
  56. data/test/functional/test_helper.rb +7 -0
  57. data/test/test_helper.rb +27 -0
  58. data/test/unit/apipie_resource_mock.rb +24 -6
  59. data/test/unit/architecture_test.rb +1 -1
  60. data/test/unit/auth_source_ldap_test.rb +1 -3
  61. data/test/unit/common_parameter_test.rb +1 -1
  62. data/test/unit/compute_resource_test.rb +1 -1
  63. data/test/unit/data/1.10/foreman_api.json +1 -0
  64. data/test/unit/data/README.md +22 -0
  65. data/test/unit/data/test_api.json +609 -0
  66. data/test/unit/defaults_test.rb +32 -0
  67. data/test/unit/dependency_resolver_test.rb +21 -16
  68. data/test/unit/domain_test.rb +1 -1
  69. data/test/unit/environment_test.rb +1 -1
  70. data/test/unit/external_usergroup_test.rb +1 -1
  71. data/test/unit/helpers/command.rb +5 -1
  72. data/test/unit/host_test.rb +16 -8
  73. data/test/unit/hostgroup_test.rb +1 -1
  74. data/test/unit/id_resolver_test.rb +40 -37
  75. data/test/unit/image_test.rb +1 -3
  76. data/test/unit/location_test.rb +1 -1
  77. data/test/unit/media_test.rb +3 -3
  78. data/test/unit/model_test.rb +1 -1
  79. data/test/unit/operating_system_test.rb +1 -2
  80. data/test/unit/option_builders_test.rb +106 -116
  81. data/test/unit/organization_test.rb +1 -1
  82. data/test/unit/partition_table_test.rb +1 -1
  83. data/test/unit/puppet_class_test.rb +4 -1
  84. data/test/unit/report_test.rb +1 -1
  85. data/test/unit/role_test.rb +15 -0
  86. data/test/unit/smart_class_parameter_test.rb +1 -1
  87. data/test/unit/smart_proxy_test.rb +1 -1
  88. data/test/unit/smart_variable_test.rb +1 -1
  89. data/test/unit/subnet_test.rb +1 -1
  90. data/test/unit/template_test.rb +1 -1
  91. data/test/unit/test_helper.rb +2 -29
  92. data/test/unit/user_test.rb +1 -2
  93. metadata +67 -539
  94. data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand-parameters.xml +0 -11
  95. data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand.xml +0 -7
  96. data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand-parameters.xml +0 -13
  97. data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand.xml +0 -7
  98. data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-output.xml +0 -13
  99. data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-parameters.xml +0 -13
  100. data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand.xml +0 -7
  101. data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-output.xml +0 -13
  102. data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-parameters.xml +0 -17
  103. data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand.xml +0 -7
  104. data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand-parameters.xml +0 -15
  105. data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand.xml +0 -7
  106. data/test/reports/TEST-HammerCLIForeman-Architecture.xml +0 -7
  107. data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand-parameters.xml +0 -11
  108. data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand.xml +0 -7
  109. data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-output.xml +0 -13
  110. data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-parameters.xml +0 -17
  111. data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand.xml +0 -7
  112. data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand-parameters.xml +0 -13
  113. data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand.xml +0 -7
  114. data/test/reports/TEST-HammerCLIForeman-CommonParameter.xml +0 -7
  115. data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand-parameters.xml +0 -15
  116. data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand.xml +0 -7
  117. data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand-parameters.xml +0 -13
  118. data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand.xml +0 -7
  119. data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-output.xml +0 -17
  120. data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-parameters.xml +0 -13
  121. data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand.xml +0 -7
  122. data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-output.xml +0 -15
  123. data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-parameters.xml +0 -17
  124. data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand.xml +0 -7
  125. data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand-parameters.xml +0 -15
  126. data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand.xml +0 -7
  127. data/test/reports/TEST-HammerCLIForeman-ComputeResource.xml +0 -7
  128. data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand-parameters.xml +0 -11
  129. data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand.xml +0 -7
  130. data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand-parameters.xml +0 -13
  131. data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand.xml +0 -7
  132. data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand-parameters.xml +0 -15
  133. data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand.xml +0 -7
  134. data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-output.xml +0 -21
  135. data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-parameters.xml +0 -13
  136. data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand.xml +0 -7
  137. data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-output.xml +0 -13
  138. data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-parameters.xml +0 -17
  139. data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand.xml +0 -7
  140. data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand-parameters.xml +0 -17
  141. data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand.xml +0 -7
  142. data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand-parameters.xml +0 -15
  143. data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand.xml +0 -7
  144. data/test/reports/TEST-HammerCLIForeman-Domain.xml +0 -7
  145. data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand-parameters.xml +0 -11
  146. data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand.xml +0 -7
  147. data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand-parameters.xml +0 -13
  148. data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand.xml +0 -7
  149. data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-output.xml +0 -17
  150. data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-parameters.xml +0 -13
  151. data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand.xml +0 -7
  152. data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-output.xml +0 -13
  153. data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-parameters.xml +0 -17
  154. data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand.xml +0 -7
  155. data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand-parameters.xml +0 -15
  156. data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand.xml +0 -7
  157. data/test/reports/TEST-HammerCLIForeman-Environment.xml +0 -7
  158. data/test/reports/TEST-HammerCLIForeman-ExceptionHandler.xml +0 -13
  159. data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand-parameters.xml +0 -46
  160. data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand.xml +0 -7
  161. data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand-parameters.xml +0 -13
  162. data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand.xml +0 -7
  163. data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand-parameters.xml +0 -15
  164. data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand.xml +0 -7
  165. data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-output.xml +0 -85
  166. data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-parameters.xml +0 -13
  167. data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand.xml +0 -7
  168. data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-output.xml +0 -21
  169. data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-parameters.xml +0 -17
  170. data/test/reports/TEST-HammerCLIForeman-Host-ListCommand.xml +0 -7
  171. data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand-output.xml +0 -9
  172. data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand.xml +0 -7
  173. data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand-parameters.xml +0 -17
  174. data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand.xml +0 -7
  175. data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand-output.xml +0 -9
  176. data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand.xml +0 -7
  177. data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand-parameters.xml +0 -40
  178. data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand.xml +0 -7
  179. data/test/reports/TEST-HammerCLIForeman-Host.xml +0 -7
  180. data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand-parameters.xml +0 -11
  181. data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand.xml +0 -7
  182. data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand-parameters.xml +0 -11
  183. data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand.xml +0 -7
  184. data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand-parameters.xml +0 -13
  185. data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand.xml +0 -7
  186. data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-output.xml +0 -29
  187. data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-parameters.xml +0 -11
  188. data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand.xml +0 -7
  189. data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-output.xml +0 -27
  190. data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-parameters.xml +0 -17
  191. data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand.xml +0 -7
  192. data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand-parameters.xml +0 -15
  193. data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand.xml +0 -7
  194. data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand-parameters.xml +0 -13
  195. data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand.xml +0 -7
  196. data/test/reports/TEST-HammerCLIForeman-Hostgroup.xml +0 -7
  197. data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-parameters.xml +0 -11
  198. data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-resource-disabled.xml +0 -11
  199. data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand.xml +0 -7
  200. data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-parameters.xml +0 -13
  201. data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-resource-disabled.xml +0 -11
  202. data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand.xml +0 -7
  203. data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-output.xml +0 -17
  204. data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-parameters.xml +0 -13
  205. data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-resource-disabled.xml +0 -11
  206. data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand.xml +0 -7
  207. data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-output.xml +0 -13
  208. data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-parameters.xml +0 -17
  209. data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-resource-disabled.xml +0 -11
  210. data/test/reports/TEST-HammerCLIForeman-Location-ListCommand.xml +0 -7
  211. data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-parameters.xml +0 -15
  212. data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-resource-disabled.xml +0 -11
  213. data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand.xml +0 -7
  214. data/test/reports/TEST-HammerCLIForeman-Location.xml +0 -7
  215. data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand-parameters.xml +0 -13
  216. data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand.xml +0 -7
  217. data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand-parameters.xml +0 -13
  218. data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand.xml +0 -7
  219. data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-output.xml +0 -23
  220. data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-parameters.xml +0 -13
  221. data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand.xml +0 -7
  222. data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-output.xml +0 -15
  223. data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-parameters.xml +0 -17
  224. data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand.xml +0 -7
  225. data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand-parameters.xml +0 -17
  226. data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand.xml +0 -7
  227. data/test/reports/TEST-HammerCLIForeman-Medium.xml +0 -7
  228. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand-parameters.xml +0 -11
  229. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand.xml +0 -7
  230. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand-parameters.xml +0 -13
  231. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand.xml +0 -7
  232. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand-parameters.xml +0 -13
  233. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand.xml +0 -7
  234. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-output.xml +0 -27
  235. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-parameters.xml +0 -13
  236. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand.xml +0 -7
  237. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-output.xml +0 -17
  238. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-parameters.xml +0 -17
  239. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand.xml +0 -7
  240. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand-parameters.xml +0 -15
  241. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand.xml +0 -7
  242. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand-parameters.xml +0 -17
  243. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand.xml +0 -7
  244. data/test/reports/TEST-HammerCLIForeman-OperatingSystem.xml +0 -7
  245. data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-parameters.xml +0 -11
  246. data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-resource-disabled.xml +0 -11
  247. data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand.xml +0 -7
  248. data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-parameters.xml +0 -13
  249. data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-resource-disabled.xml +0 -11
  250. data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand.xml +0 -7
  251. data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-output.xml +0 -17
  252. data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-parameters.xml +0 -13
  253. data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-resource-disabled.xml +0 -11
  254. data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand.xml +0 -7
  255. data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-output.xml +0 -13
  256. data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-parameters.xml +0 -17
  257. data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-resource-disabled.xml +0 -11
  258. data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand.xml +0 -7
  259. data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-parameters.xml +0 -15
  260. data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-resource-disabled.xml +0 -11
  261. data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand.xml +0 -7
  262. data/test/reports/TEST-HammerCLIForeman-Organization.xml +0 -7
  263. data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand-parameters.xml +0 -13
  264. data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand.xml +0 -7
  265. data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand-parameters.xml +0 -13
  266. data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand.xml +0 -7
  267. data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand-parameters.xml +0 -15
  268. data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand.xml +0 -7
  269. data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-output.xml +0 -19
  270. data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-parameters.xml +0 -13
  271. data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand.xml +0 -7
  272. data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-output.xml +0 -15
  273. data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-parameters.xml +0 -17
  274. data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand.xml +0 -7
  275. data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand-parameters.xml +0 -13
  276. data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand.xml +0 -7
  277. data/test/reports/TEST-HammerCLIForeman-PartitionTable.xml +0 -7
  278. data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand-parameters.xml +0 -13
  279. data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand.xml +0 -7
  280. data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand-parameters.xml +0 -13
  281. data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand.xml +0 -7
  282. data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-output.xml +0 -21
  283. data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-parameters.xml +0 -13
  284. data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand.xml +0 -7
  285. data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-output.xml +0 -15
  286. data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-parameters.xml +0 -11
  287. data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand.xml +0 -7
  288. data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand-parameters.xml +0 -15
  289. data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand.xml +0 -7
  290. data/test/reports/TEST-HammerCLIForeman-SmartProxy.xml +0 -7
  291. data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand-parameters.xml +0 -15
  292. data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand.xml +0 -7
  293. data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand-parameters.xml +0 -13
  294. data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand.xml +0 -7
  295. data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-output.xml +0 -43
  296. data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-parameters.xml +0 -13
  297. data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand.xml +0 -7
  298. data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-output.xml +0 -17
  299. data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-parameters.xml +0 -17
  300. data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand.xml +0 -7
  301. data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand-parameters.xml +0 -15
  302. data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand.xml +0 -7
  303. data/test/reports/TEST-HammerCLIForeman-Subnet.xml +0 -7
  304. data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand-parameters.xml +0 -15
  305. data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand.xml +0 -7
  306. data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand-parameters.xml +0 -11
  307. data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand.xml +0 -7
  308. data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand-parameters.xml +0 -12
  309. data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand.xml +0 -7
  310. data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-output.xml +0 -17
  311. data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-parameters.xml +0 -11
  312. data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand.xml +0 -7
  313. data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-output.xml +0 -15
  314. data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-parameters.xml +0 -17
  315. data/test/reports/TEST-HammerCLIForeman-Template-ListCommand.xml +0 -7
  316. data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand-parameters.xml +0 -9
  317. data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand.xml +0 -7
  318. data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand-parameters.xml +0 -11
  319. data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand.xml +0 -7
  320. data/test/reports/TEST-HammerCLIForeman-Template.xml +0 -7
  321. data/test/reports/TEST-HammerCLIForeman-User-CreateCommand-parameters.xml +0 -19
  322. data/test/reports/TEST-HammerCLIForeman-User-CreateCommand.xml +0 -7
  323. data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand-parameters.xml +0 -11
  324. data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand.xml +0 -7
  325. data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-output.xml +0 -23
  326. data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-parameters.xml +0 -11
  327. data/test/reports/TEST-HammerCLIForeman-User-InfoCommand.xml +0 -7
  328. data/test/reports/TEST-HammerCLIForeman-User-ListCommand-output.xml +0 -17
  329. data/test/reports/TEST-HammerCLIForeman-User-ListCommand-parameters.xml +0 -17
  330. data/test/reports/TEST-HammerCLIForeman-User-ListCommand.xml +0 -7
  331. data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand-parameters.xml +0 -11
  332. data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand.xml +0 -7
  333. data/test/reports/TEST-HammerCLIForeman-User.xml +0 -7
  334. data/test/reports/TEST-MiniTest-Spec.xml +0 -7
  335. data/test/unit/data/1.4/foreman_api.json +0 -10387
  336. data/test/unit/data/1.5/foreman_api.json +0 -14130
  337. data/test/unit/data/1.6/foreman_api.json +0 -1
  338. data/test/unit/data/1.6/foreman_api_back.json +0 -1
  339. data/test/unit/data/1.6/whatever.json +0 -1
  340. data/test/unit/data/1.7/foreman_api.json +0 -1
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+ describe HammerCLIForeman::Defaults do
3
+
4
+ context "Defaults" do
5
+
6
+ defaults_provider = HammerCLIForeman::Defaults.new
7
+ user = {"results" => ["default_organization" => {"id" => 2}, "default_location" => {"id" => 1}]}
8
+ empty_user = {"results" => ["default_organization" => nil, "default_location" => nil]}
9
+
10
+ it "returns defaults organization when exisits " do
11
+ defaults_provider.stubs(:get_user).returns user
12
+ assert_equal 2, defaults_provider.get_defaults(:organization_id)
13
+ end
14
+
15
+ it "returns nil when defaults organization doesn't exisits " do
16
+ defaults_provider.stubs(:get_user).returns empty_user
17
+ assert_nil defaults_provider.get_defaults(:organization_id)
18
+ end
19
+
20
+ it "returns defaults location when exisits " do
21
+ defaults_provider.stubs(:get_user).returns user
22
+ assert_equal 1, defaults_provider.get_defaults(:location_id)
23
+ end
24
+
25
+ it "returns nil when defaults location doesn't exisits " do
26
+ defaults_provider.stubs(:get_user).returns empty_user
27
+ assert_nil defaults_provider.get_defaults(:location_id)
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -4,41 +4,46 @@ require File.join(File.dirname(__FILE__), 'helpers/fake_searchables')
4
4
 
5
5
  describe HammerCLIForeman::DependencyResolver do
6
6
 
7
+ let(:api) do ApipieBindings::API.new({
8
+ :apidoc_cache_dir => 'test/unit/data',
9
+ :apidoc_cache_name => 'test_api',
10
+ :dry_run => true})
11
+ end
12
+
13
+ before :each do
14
+ HammerCLIForeman.stubs(:foreman_api).returns(api)
15
+ end
16
+
7
17
  let(:resolver) { HammerCLIForeman::DependencyResolver.new }
8
18
 
9
19
  describe "for resource" do
10
20
 
11
21
  it "returns empty array for an independent resource" do
12
- resource = HammerCLIForeman.foreman_resource!(:architectures)
22
+ resource = api.resource(:users)
13
23
  resolver.resource_dependencies(resource).must_equal []
14
24
  end
15
25
 
16
26
  it "returns list of dependent resources" do
17
- resource = HammerCLIForeman.foreman_resource!(:images)
18
- resolver.resource_dependencies(resource).map(&:name).sort_by{|sym| sym.to_s}.must_equal [
19
- :compute_resources, :organizations, :locations
20
- ].sort_by{|sym| sym.to_s}
21
- end
27
+ resource = api.resource(:comments)
22
28
 
29
+ resources = resolver.resource_dependencies(resource).map(&:name).sort_by{ |sym| sym.to_s }
30
+ expected = [:posts, :users]
31
+ resources.must_equal expected.sort_by{ |sym| sym.to_s }
32
+ end
23
33
  end
24
34
 
25
35
  describe "for action" do
26
36
 
27
37
  it "returns empty array for an independent action" do
28
- action = HammerCLIForeman.foreman_resource!(:organizations).action(:index)
38
+ action = HammerCLIForeman.foreman_resource!(:users).action(:index)
29
39
  resolver.action_dependencies(action).must_equal []
30
40
  end
31
41
 
32
42
  it "returns list of dependent resources" do
33
- action = HammerCLIForeman.foreman_resource!(:hostgroups).action(:create)
34
- resolver.action_dependencies(action).map(&:name).sort_by{|sym| sym.to_s}.must_equal [
35
- :environments, :operatingsystems, :architectures, :media,
36
- :ptables, :subnets, :domains, :realms, :organizations, :locations
37
- ].sort_by{|sym| sym.to_s}
43
+ action = HammerCLIForeman.foreman_resource!(:comments).action(:create)
44
+ resources = resolver.action_dependencies(action).map(&:name).sort_by{ |sym| sym.to_s }
45
+ expected = [:posts, :users]
46
+ resources.must_equal expected.sort_by{|sym| sym.to_s}
38
47
  end
39
-
40
48
  end
41
-
42
49
  end
43
-
44
-
@@ -17,7 +17,7 @@ describe HammerCLIForeman::Domain do
17
17
  end
18
18
 
19
19
  context "output" do
20
- let(:expected_record_count) { cmd.resource.call(:index).length }
20
+ let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
21
21
 
22
22
  it_should_print_n_records
23
23
  it_should_print_columns ["Id", "Name"]
@@ -17,7 +17,7 @@ describe HammerCLIForeman::Environment do
17
17
  end
18
18
 
19
19
  context "output" do
20
- let(:expected_record_count) { cmd.resource.call(:index).length }
20
+ let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
21
21
 
22
22
  it_should_print_n_records
23
23
  it_should_print_column "Name"
@@ -20,7 +20,7 @@ describe HammerCLIForeman::ExternalUsergroup do
20
20
  end
21
21
 
22
22
  context "output" do
23
- let(:expected_record_count) { cmd.resource.call(:index, :usergroup_id => 1).length }
23
+ let(:expected_record_count) { count_records(cmd.resource.call(:index, :usergroup_id => 1)) }
24
24
 
25
25
  with_params ["--user-group-id=1"] do
26
26
  it_should_print_n_records
@@ -24,7 +24,7 @@ class IdResolverTestProxy
24
24
 
25
25
  method_name = "#{resource.singular_name}_ids"
26
26
  self.class.send(:define_method, method_name) do |options|
27
- [1]
27
+ options["option_#{resource.singular_name}_ids"].nil? ? nil : [1]
28
28
  end
29
29
  end
30
30
  end
@@ -43,6 +43,10 @@ module CommandTestHelper
43
43
  end
44
44
  end
45
45
 
46
+ def count_records(data)
47
+ HammerCLIForeman.collection_to_common_format(data['results']).count
48
+ end
49
+
46
50
  module ClassMethods
47
51
 
48
52
  def with_params(params, &block)
@@ -17,7 +17,7 @@ describe HammerCLIForeman::Host do
17
17
  end
18
18
 
19
19
  context "output" do
20
- let(:expected_record_count) { cmd.resource.call(:index).length }
20
+ let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
21
21
 
22
22
  it_should_print_n_records
23
23
  it_should_print_columns ["Id", "Name", "Operating System", "Host Group", "IP", "MAC"]
@@ -73,7 +73,7 @@ describe HammerCLIForeman::Host do
73
73
 
74
74
  it "should output status" do
75
75
  cmd.stubs(:context).returns(ctx.update(:adapter => :test))
76
- proc { cmd.run(with_params) }.must_output "#Status#Power#\n#missing#running#\n"
76
+ proc { cmd.run(with_params) }.must_output "#Status#Power#\n#No reports#running#\n"
77
77
  end
78
78
  end
79
79
  end
@@ -160,7 +160,7 @@ describe HammerCLIForeman::Host do
160
160
 
161
161
  context "output" do
162
162
  with_params ["--id=1"] do
163
- let(:expected_record_count) { cmd.resource.call(:index)[0].length }
163
+ let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
164
164
 
165
165
  it_should_print_n_records
166
166
  it_should_print_column "Id"
@@ -202,7 +202,7 @@ describe HammerCLIForeman::Host do
202
202
  it_should_accept "name, environment_id, architecture_id, domain_id, puppet_proxy_id, operatingsystem_id and more",
203
203
  ["--name=host", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1",
204
204
  "--ip=1.2.3.4", "--mac=11:22:33:44:55:66", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1",
205
- "--sp-subnet-id=1", "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids',
205
+ "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids',
206
206
  "--root-password=pwd", "--ask-root-password=true", "--provision-method=build", "--interface=primary=true,provision=true"]
207
207
  it_should_fail_with "name or id missing",
208
208
  ["--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1", "--interface=primary=true,provision=true"]
@@ -221,7 +221,7 @@ describe HammerCLIForeman::Host do
221
221
 
222
222
  with_params ["--name=host", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1",
223
223
  "--ip=1.2.3.4", "--mac=11:22:33:44:55:66", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1",
224
- "--sp-subnet-id=1", "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids',
224
+ "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids',
225
225
  "--root-password=pwd", "--ask-root-password=true", "--provision-method=build", "--interface=primary=true,provision=true"] do
226
226
  it_should_call_action_and_test_params(:create) { |par| par["host"]["managed"] == true }
227
227
  it_should_call_action_and_test_params(:create) { |par| par["host"]["build"] == true }
@@ -231,8 +231,11 @@ describe HammerCLIForeman::Host do
231
231
  it_should_call_action_and_test_params(:create) { |par| par["host"]["interfaces_attributes"]["0"]["provision"] == "true" }
232
232
  end
233
233
 
234
- with_params ["--name=host", "--hostgroup-id=1", "--interface=primary=true,provision=true", "--parameters=servers=[pool.ntp.org,ntp.time.org]"] do
235
- it_should_call_action_and_test_params(:create) { |par| par["host"]["host_parameters_attributes"][0]["value"] == "[\"pool.ntp.org\", \"ntp.time.org\"]" }
234
+ with_params ["--name=host", "--hostgroup-id=1", "--interface=primary=true,provision=true", "--parameters=servers=[pool.ntp.org,ntp.time.org],password=secret"] do
235
+ it_should_call_action_and_test_params(:create) do |par|
236
+ par["host"]["host_parameters_attributes"][0]["value"] == "[\"pool.ntp.org\", \"ntp.time.org\"]" &&
237
+ par["host"]["host_parameters_attributes"][1]["value"] == "secret"
238
+ end
236
239
  end
237
240
 
238
241
  it_should_fail_with "primary interface missing", ["--hostgroup-id=example", "--interface=primary=true"]
@@ -253,7 +256,7 @@ describe HammerCLIForeman::Host do
253
256
  it_should_accept "id and more", ["--id=1", "--new-name=host2", "--environment-id=1", "--architecture-id=1",
254
257
  "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1",
255
258
  "--ip=1.2.3.4", "--mac=11:22:33:44:55:66", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1",
256
- "--sp-subnet-id=1", "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1',
259
+ "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1',
257
260
  "--root-password=pwd", "--ask-root-password=true", "--provision-method=build"]
258
261
  # it_should_fail_with "no params", []
259
262
  # it_should_fail_with "name or id missing", ["--new-name=host2"]
@@ -263,6 +266,7 @@ describe HammerCLIForeman::Host do
263
266
  it_should_call_action_and_test_params(:update) { |par| par["host"].key?("managed") != true }
264
267
  it_should_call_action_and_test_params(:update) { |par| par["host"].key?("build") != true }
265
268
  it_should_call_action_and_test_params(:update) { |par| par["host"].key?("enabled") != true }
269
+ it_should_call_action_and_test_params(:update) { |par| par["host"].key?("overwrite") != true }
266
270
  end
267
271
 
268
272
  with_params ["--id=1", "--enabled=true"] do
@@ -273,6 +277,10 @@ describe HammerCLIForeman::Host do
273
277
  it_should_call_action_and_test_params(:update) { |par| par["host"]["enabled"] == false }
274
278
  end
275
279
 
280
+ with_params ["--id=1", "--overwrite=true"] do
281
+ it_should_call_action_and_test_params(:update) { |par| par["host"]["overwrite"] == true }
282
+ end
283
+
276
284
  with_params ["--id=1","--provision-method=build"] do
277
285
  it_should_call_action_and_test_params(:update) { |par| par["host"]["provision_method"] == "build" }
278
286
  end
@@ -17,7 +17,7 @@ describe HammerCLIForeman::Hostgroup do
17
17
  end
18
18
 
19
19
  context "output" do
20
- let(:expected_record_count) { cmd.resource.call(:index).length }
20
+ let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
21
21
 
22
22
  it_should_print_n_records
23
23
  it_should_print_columns ["Id", "Name", "Title", "Operating System"]
@@ -4,7 +4,11 @@ require File.join(File.dirname(__FILE__), 'helpers/fake_searchables')
4
4
 
5
5
  describe HammerCLIForeman::IdResolver do
6
6
 
7
- let(:api) { HammerCLIForeman.foreman_api_connection.api }
7
+ let(:api) do ApipieBindings::API.new({
8
+ :apidoc_cache_dir => 'test/unit/data',
9
+ :apidoc_cache_name => 'test_api',
10
+ :dry_run => true})
11
+ end
8
12
  let(:searchables) { FakeSearchables.new(['name','label']) }
9
13
  let(:resolver) { HammerCLIForeman::IdResolver.new(api, searchables) }
10
14
 
@@ -66,7 +70,7 @@ describe HammerCLIForeman::IdResolver do
66
70
  end
67
71
 
68
72
  describe "when no search options are found" do
69
- let(:resolver_run) { proc { resolver.architecture_id({"option_unknown" => "value"}) } }
73
+ let(:resolver_run) { proc { resolver.comment_id({"option_unknown" => "value"}) } }
70
74
 
71
75
  it "raises exception" do
72
76
  err = resolver_run.must_raise HammerCLIForeman::MissingSeachOptions
@@ -74,49 +78,49 @@ describe HammerCLIForeman::IdResolver do
74
78
 
75
79
  it "builds correct error message" do
76
80
  err = resolver_run.must_raise HammerCLIForeman::MissingSeachOptions
77
- err.message.must_equal "Missing options to search architecture"
81
+ err.message.must_equal "Missing options to search comment"
78
82
  end
79
83
  end
80
84
 
81
85
  describe "searching independent resource" do
82
- let(:resolver_run) { proc { resolver.architecture_id({"option_name" => "arch"}) } }
86
+ let(:resolver_run) { proc { resolver.user_id({"option_name" => "John Doe"}) } }
83
87
 
84
88
  it "raises exception when no resource is found" do
85
- ResourceMocks.mock_action_call(:architectures, :index, [])
89
+ ResourceMocks.mock_action_call(:users, :index, [])
86
90
 
87
91
  err = resolver_run.must_raise HammerCLIForeman::ResolverError
88
- err.message.must_equal "architecture not found"
92
+ err.message.must_equal "user not found"
89
93
  end
90
94
 
91
95
  it "raises exception when multiple resources are found" do
92
- ResourceMocks.mock_action_call(:architectures, :index, [
93
- {"id" => 11, "name" => "arch1"},
94
- {"id" => 22, "name" => "arch2"}
96
+ ResourceMocks.mock_action_call(:users, :index, [
97
+ {"id" => 11, "name" => "user11"},
98
+ {"id" => 22, "name" => "user22"}
95
99
  ])
96
100
 
97
101
  err = resolver_run.must_raise HammerCLIForeman::ResolverError
98
- err.message.must_equal "architecture found more than once"
102
+ err.message.must_equal "found more than one user"
99
103
  end
100
104
 
101
105
  it "calls index action with appropriate search params" do
102
106
  ApipieBindings::API.any_instance.expects(:call).with() do |resource, action, params, headers, opts|
103
- ( resource == :architectures &&
107
+ ( resource == :users &&
104
108
  action == :index &&
105
- params[:search] == "name = \"arch\"")
106
- end.returns({"id" => 11, "name" => "arch1"})
109
+ params[:search] == "name = \"John Doe\"")
110
+ end.returns({"id" => 1, "name" => "John Doe"})
107
111
 
108
112
  resolver_run.call
109
113
  end
110
114
 
111
115
  it "uses option id when it's available" do
112
- ResourceMocks.mock_action_call(:architectures, :index, [])
116
+ ResourceMocks.mock_action_call(:users, :index, [])
113
117
 
114
- resolver.architecture_id({"option_id" => 83, "option_name" => "arch"}).must_equal 83
118
+ resolver.user_id({"option_id" => 83, "option_name" => "John Doe"}).must_equal 83
115
119
  end
116
120
 
117
121
  it "returns id of the resource" do
118
- ResourceMocks.mock_action_call(:architectures, :index, [
119
- {"id" => 11, "name" => "arch1"}
122
+ ResourceMocks.mock_action_call(:users, :index, [
123
+ {"id" => 11, "name" => "John Doe"}
120
124
  ])
121
125
 
122
126
  resolver_run.call.must_equal 11
@@ -125,51 +129,50 @@ describe HammerCLIForeman::IdResolver do
125
129
  end
126
130
 
127
131
  describe "searching dependent resources" do
128
- let(:resolver_run) { proc { resolver.image_id({"option_name" => "img", "option_compute_resource_name" => "cr"}) } }
132
+ let(:resolver_run) { proc { resolver.post_id({"option_name" => "Post 11", "option_user_name" => "User 22"}) } }
129
133
 
130
134
  it "raises exception when no resource is found" do
131
- ResourceMocks.mock_action_call(:images, :index, [])
132
- ResourceMocks.mock_action_call(:compute_resources, :index, [])
135
+ ResourceMocks.mock_action_call(:posts, :index, [])
136
+ ResourceMocks.mock_action_call(:users, :index, [])
133
137
 
134
138
  err = resolver_run.must_raise HammerCLIForeman::ResolverError
135
- err.message.must_equal "compute_resource not found"
139
+ err.message.must_equal "user not found"
136
140
  end
137
141
 
138
142
  it "raises exception when multiple resources are found" do
139
- ResourceMocks.mock_action_call(:images, :index, [])
140
- ResourceMocks.mock_action_call(:compute_resources, :index, [
141
- {"id" => 11, "name" => "cr1"},
142
- {"id" => 22, "name" => "cr2"}
143
+ ResourceMocks.mock_action_call(:posts, :index, [])
144
+ ResourceMocks.mock_action_call(:users, :index, [
145
+ {"id" => 11, "name" => "user1"},
146
+ {"id" => 22, "name" => "user2"}
143
147
  ])
144
148
 
145
149
  err = resolver_run.must_raise HammerCLIForeman::ResolverError
146
- err.message.must_equal "compute_resource found more than once"
150
+ err.message.must_equal "found more than one user"
147
151
  end
148
152
 
149
153
  it "calls index action with appropriate search params" do
150
154
  ApipieBindings::API.any_instance.expects(:call).with() do |resource, action, params, headers, opts|
151
- ( resource == :compute_resources &&
155
+ ( resource == :users &&
152
156
  action == :index &&
153
- params[:search] == "name = \"cr\"")
154
- end.returns({"id" => 11, "name" => "cr"})
157
+ params[:search] == "name = \"User 22\"")
158
+ end.returns({"id" => 22, "name" => "User 22"})
155
159
 
156
160
  ApipieBindings::API.any_instance.expects(:call).with() do |resource, action, params, headers, opts|
157
- ( resource == :images &&
161
+ ( resource == :posts &&
158
162
  action == :index &&
159
- params[:search] == "name = \"img\"")
160
- end.returns({"id" => 11, "name" => "img"})
163
+ params[:search] == "name = \"Post 11\"")
164
+ end.returns({"id" => 11, "name" => "Post 11"})
161
165
 
162
166
  resolver_run.call
163
167
  end
164
168
 
165
169
  it "returns id of the resource" do
166
- ResourceMocks.mock_action_call(:images, :index, [
167
- {"id" => 11, "name" => "img1"}
170
+ ResourceMocks.mock_action_call(:posts, :index, [
171
+ {"id" => 11, "name" => "Post 11"}
168
172
  ])
169
- ResourceMocks.mock_action_call(:compute_resources, :index, [
170
- {"id" => 22, "name" => "cr2"}
173
+ ResourceMocks.mock_action_call(:users, :index, [
174
+ {"id" => 22, "name" => "User 22"}
171
175
  ])
172
-
173
176
  resolver_run.call.must_equal 11
174
177
  end
175
178
  end
@@ -20,7 +20,7 @@ describe HammerCLIForeman::Image do
20
20
  end
21
21
 
22
22
  context "output" do
23
- let(:expected_record_count) { cmd.resource.call(:index, :compute_resource_id=>1).length }
23
+ let(:expected_record_count) { count_records(cmd.resource.call(:index, :compute_resource_id=>1)) }
24
24
 
25
25
  with_params ["--compute-resource-id=1"] do
26
26
  it_should_print_n_records
@@ -130,5 +130,3 @@ describe HammerCLIForeman::Image do
130
130
  end
131
131
 
132
132
  end
133
-
134
-
@@ -22,7 +22,7 @@ describe HammerCLIForeman::Location do
22
22
  end
23
23
 
24
24
  context "output" do
25
- let(:expected_record_count) { cmd.resource.call(:index).length }
25
+ let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
26
26
 
27
27
  it_should_print_n_records
28
28
  it_should_print_column "Name"
@@ -17,7 +17,7 @@ describe HammerCLIForeman::Medium do
17
17
  end
18
18
 
19
19
  context "output" do
20
- let(:expected_record_count) { cmd.resource.call(:index).length }
20
+ let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
21
21
 
22
22
  it_should_print_n_records
23
23
  it_should_print_column "Name"
@@ -63,7 +63,7 @@ describe HammerCLIForeman::Medium do
63
63
  end
64
64
 
65
65
  with_params ["--name=medium_x", "--path=http://some.path/", "--operatingsystem-ids=1,2"] do
66
- it_should_call_action :create, {'medium' => {'name' => 'medium_x', 'path' => 'http://some.path/', 'operatingsystem_ids' => [1], 'location_ids' => [1], 'organization_ids' => [1]}}
66
+ it_should_call_action :create, {'medium' => {'name' => 'medium_x', 'path' => 'http://some.path/', 'operatingsystem_ids' => [1]}}
67
67
  end
68
68
  end
69
69
 
@@ -92,7 +92,7 @@ describe HammerCLIForeman::Medium do
92
92
  end
93
93
 
94
94
  with_params ["--id=1", "--new-name=medium_x", "--path=http://some.path/", "--operatingsystem-ids=1,2"] do
95
- it_should_call_action :update, {'id' => '1', 'name' => 'medium_x', 'medium' => {'name' => 'medium_x', 'path' => 'http://some.path/', 'operatingsystem_ids' => [1], 'location_ids' => [1], 'organization_ids' => [1]}}
95
+ it_should_call_action :update, {'id' => '1', 'name' => 'medium_x', 'medium' => {'name' => 'medium_x', 'path' => 'http://some.path/', 'operatingsystem_ids' => [1]}}
96
96
  end
97
97
 
98
98
  end