Example #1
0
 def test_do_create(self, args, lib, noprefix):
     bopts = testbOpts()
     p = testPulp()
     (flexmock(Pulp).new_instances(p).once().with_args(
         Pulp, env=bopts.server, config_file=bopts.config_file))
     args = args.split(" ")
     bargs = args[:]
     if lib:
         bargs.append('-l')
     if noprefix:
         bargs.append('--noprefix')
     flexmock(testPulp)
     if not noprefix:
         (testPulp.should_receive('getPrefix').once().and_return('redhat-'))
     (testPulp.should_receive('isRedirect').and_return(True))
     (testPulp.should_receive('createRepo').and_return(None))
     if lib and len(args) != 2:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not lib and len(args) != 3:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not args[-1].startswith('/content'):
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     else:
         assert cli.do_create(bopts, bargs) is None
Example #2
0
 def test_do_create(self, mocked_pulp, args, lib, noprefix, download):
     bopts = testbOpts()
     p = testPulp()
     mocked_pulp.side_effect = [p]
     args = args.split(" ")
     bargs = args[:]
     if lib:
         bargs.append('-l')
     if noprefix:
         bargs.append('--noprefix')
     bargs.append('--download')
     bargs.append(download)
     flexmock(testPulp)
     if not noprefix:
         (testPulp
             .should_receive('getPrefix')
             .once()
             .and_return('redhat-'))
     (testPulp
         .should_receive('isRedirect')
         .and_return(True))
     if not lib and noprefix and download == "true" and args[-1].startswith('/content') \
        and args[0] == 'foo':
         (testPulp
             .should_receive('createRepo')
             .with_args('foo-bar', '/content/foo-bar', library=lib, title=None,
                        productline='foo', distribution=None, desc="No description",
                        prefix_with='', rel_url='content/foo-bar', download=True)
             .and_return(None))
     else:
         (testPulp
             .should_receive('createRepo')
             .and_return(None))
     if lib and len(args) != 2:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not lib and len(args) != 3:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not args[-1].startswith('/content'):
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not noprefix:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     else:
         assert cli.do_create(bopts, bargs) is None
Example #3
0
 def test_do_create(self, args, lib, noprefix, download):
     bopts = testbOpts()
     p = testPulp()
     (flexmock(Pulp).new_instances(p).once().with_args(
         Pulp, env=bopts.server, config_file=bopts.config_file))
     args = args.split(" ")
     bargs = args[:]
     if lib:
         bargs.append('-l')
     if noprefix:
         bargs.append('--noprefix')
     bargs.append('--download')
     bargs.append(download)
     flexmock(testPulp)
     if not noprefix:
         (testPulp.should_receive('getPrefix').once().and_return('redhat-'))
     (testPulp.should_receive('isRedirect').and_return(True))
     if not lib and noprefix and download == "true" and args[-1].startswith('/content') \
        and args[0] == 'foo':
         (testPulp.should_receive('createRepo').with_args(
             'foo-bar',
             '/content/foo-bar',
             library=lib,
             protected=False,
             title=None,
             productline='foo',
             distribution=None,
             desc="No description",
             prefix_with='',
             rel_url='content/foo-bar',
             download=True).and_return(None))
     else:
         (testPulp.should_receive('createRepo').and_return(None))
     if lib and len(args) != 2:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not lib and len(args) != 3:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not args[-1].startswith('/content'):
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not noprefix:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     else:
         assert cli.do_create(bopts, bargs) is None
Example #4
0
 def test_do_create(self, args, lib, noprefix):
     bopts = testbOpts()
     p = testPulp()
     (flexmock(Pulp)
         .new_instances(p)
         .once()
         .with_args(Pulp, env=bopts.server, config_file=bopts.config_file))
     args = args.split(" ")
     bargs = args[:]
     if lib:
         bargs.append('-l')
     if noprefix:
         bargs.append('--noprefix')
     flexmock(testPulp)
     if not noprefix:
         (testPulp
             .should_receive('getPrefix')
             .once()
             .and_return('redhat-'))
     (testPulp
         .should_receive('isRedirect')
         .and_return(True))
     (testPulp
         .should_receive('createRepo')
         .and_return(None))
     if lib and len(args) != 2:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not lib and len(args) != 3:
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     elif not args[-1].startswith('/content'):
         with pytest.raises(SystemExit):
             cli.do_create(bopts, bargs)
     else:
         assert cli.do_create(bopts, bargs) is None