Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Include Candlepin client Ruby lib:
- $:.unshift File.expand_path("../../../client/ruby/", __FILE__)
- require 'candlepin_api'
- module CandlepinHelperMethods
- def create_product(product_name, product_id, multiplier=1, attrs={})
- @admin_api.create_product(product_name, product_id, multiplier,
- 1, 'ALL', 'ALL', 'SVC', [], attrs)
- end
- def gen_random_string(prefix)
- "%s-%s" % [prefix, rand(100000)]
- end
- end
- # Location for setup common to all test cases:
- shared_examples_for "Candlepin tests" do
- # Included in all examples using this example group:
- include CandlepinHelperMethods
- before(:each) do
- @admin_api = Candlepin.new(username='admin', password='admin',
- cert=nil, key=nil, hostname='localhost', port=8443)
- # Create a single test owner, will be cleaned up after each test:
- @test_owner = @admin_api.create_owner(
- gen_random_string('testowner'))
- end
- after(:each) do
- # Cleanup the test owner, will clear out just about everything
- # except products.
- @admin_api.delete_owner(@test_owner['id'])
- end
- end
- describe "A user licensed pool" do
- it_should_behave_like "Candlepin tests"
- before(:each) do
- attributes = {
- 'user_license' => 'unlimited',
- 'requires_consumer_type' => 'person'}
- @user_license_product = create_product("User Licensed Product",
- 'user-licensed', 1, attributes)
- end
- after(:each) do
- end
- it "should create a user restricted pool when consumed" do
- 1.should == 1
- end
- end
- describe "A user restricted pool" do
- # Omit block = Pending
- it "should only be visible to consumers registered by that user"
- end
- describe "Subscription refresh" do
- it_should_behave_like "Candlepin tests"
- before(:each) do
- @product = create_product(gen_random_string("Test Product"),
- gen_random_string('test-product'))
- @sub = @admin_api.create_subscription(@test_owner['id'], @product['id'], 5000)
- @admin_api.refresh_pools(@test_owner['key'])
- end
- it "should create pools for new subscriptions" do
- pools_list = @admin_api.get_pools({:owner => @test_owner['id'],
- :product => @product['id']})
- pools_list.length.should == 1
- end
- it "should remove pools whose subscription disappeared" do
- @admin_api.delete_subscription(@sub['id'])
- pools_list = @admin_api.get_pools({:owner => @test_owner['id'],
- :product => @product['id']})
- pools_list.length.should == 0
- end
- end
Add Comment
Please, Sign In to add comment