Guest User

Untitled

a guest
Aug 6th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. # Include Candlepin client Ruby lib:
  2. $:.unshift File.expand_path("../../../client/ruby/", __FILE__)
  3. require 'candlepin_api'
  4.  
  5. module CandlepinHelperMethods
  6.  
  7. def create_product(product_name, product_id, multiplier=1, attrs={})
  8. @admin_api.create_product(product_name, product_id, multiplier,
  9. 1, 'ALL', 'ALL', 'SVC', [], attrs)
  10. end
  11.  
  12. def gen_random_string(prefix)
  13. "%s-%s" % [prefix, rand(100000)]
  14. end
  15.  
  16. end
  17.  
  18. # Location for setup common to all test cases:
  19. shared_examples_for "Candlepin tests" do
  20.  
  21. # Included in all examples using this example group:
  22. include CandlepinHelperMethods
  23.  
  24. before(:each) do
  25. @admin_api = Candlepin.new(username='admin', password='admin',
  26. cert=nil, key=nil, hostname='localhost', port=8443)
  27.  
  28. # Create a single test owner, will be cleaned up after each test:
  29. @test_owner = @admin_api.create_owner(
  30. gen_random_string('testowner'))
  31. end
  32.  
  33. after(:each) do
  34. # Cleanup the test owner, will clear out just about everything
  35. # except products.
  36. @admin_api.delete_owner(@test_owner['id'])
  37. end
  38.  
  39. end
  40.  
  41. describe "A user licensed pool" do
  42. it_should_behave_like "Candlepin tests"
  43.  
  44. before(:each) do
  45. attributes = {
  46. 'user_license' => 'unlimited',
  47. 'requires_consumer_type' => 'person'}
  48. @user_license_product = create_product("User Licensed Product",
  49. 'user-licensed', 1, attributes)
  50. end
  51.  
  52. after(:each) do
  53. end
  54.  
  55. it "should create a user restricted pool when consumed" do
  56. 1.should == 1
  57. end
  58.  
  59. end
  60.  
  61.  
  62. describe "A user restricted pool" do
  63.  
  64. # Omit block = Pending
  65. it "should only be visible to consumers registered by that user"
  66.  
  67. end
  68.  
  69. describe "Subscription refresh" do
  70. it_should_behave_like "Candlepin tests"
  71.  
  72. before(:each) do
  73. @product = create_product(gen_random_string("Test Product"),
  74. gen_random_string('test-product'))
  75. @sub = @admin_api.create_subscription(@test_owner['id'], @product['id'], 5000)
  76.  
  77. @admin_api.refresh_pools(@test_owner['key'])
  78. end
  79.  
  80. it "should create pools for new subscriptions" do
  81. pools_list = @admin_api.get_pools({:owner => @test_owner['id'],
  82. :product => @product['id']})
  83. pools_list.length.should == 1
  84. end
  85.  
  86. it "should remove pools whose subscription disappeared" do
  87. @admin_api.delete_subscription(@sub['id'])
  88. pools_list = @admin_api.get_pools({:owner => @test_owner['id'],
  89. :product => @product['id']})
  90. pools_list.length.should == 0
  91. end
  92.  
  93. end
Add Comment
Please, Sign In to add comment