コード例 #1
0
 def test_product_cert_output(self):
     with Capture() as cap:
         command = CatCertCommandStub(certdata.PRODUCT_CERT_V1_0)
         command.main(['will_use_stub'])
     cert_output = cap.out
     self.assert_string_equals(certdata.PRODUCT_CERT_V1_0_OUTPUT,
                               cert_output)
コード例 #2
0
 def test_omit_product_list(self):
     with Capture() as cap:
         command = CatCertCommandStub(certdata.ENTITLEMENT_CERT_V1_0)
         command.main(["not_used.pem", "--no-products"])
     cert_output = cap.out
     self.assertTrue(cert_output.find("Product:\n") == -1,
                     "Products were not excluded from the output.")
コード例 #3
0
 def _main_help(self, args):
     with Capture() as cap:
         try:
             self.cc.main(args)
         except SystemExit, e:
             # --help/-h returns 0
             self.assertEquals(e.code, 0)
コード例 #4
0
    def test_consumerid_with_distributor_id(self):
        def get_consumer(self, *args, **kwargs):
            pass

        with patch('rhsm.connection.UEPConnection',
                   new_callable=StubUEP) as mock_uep:
            mock_uep.getConsumer = get_consumer
            self.stub_cp_provider.basic_auth_cp = mock_uep

            self._inject_mock_invalid_consumer()
            cmd = RegisterCommand()
            mock_uep.getConsumer = Mock(
                return_value={
                    'uuid': '123123',
                    'type': {
                        'manifest': True
                    },
                    'idCert': {
                        'key': ''
                    }
                })
            self._inject_ipm()

            with nested(Capture(silent=True),
                        self.assertRaises(SystemExit)) as e:
                cmd.main([
                    'register', '--consumerid=TaylorSwift',
                    '--username=testuser1', '--password=password',
                    '--org=test_org'
                ])
                self.assertEquals(e.code, os.EX_USAGE)
コード例 #5
0
 def test_already_registered_to_sat_6(self):
     self._inject_mock_valid_consumer()
     self.engine.options = self.create_options(five_to_six=True)
     with Capture() as c:
         self.assertRaises(SystemExit, self.engine.check_ok_to_proceed,
                           "some_name")
         self.assertTrue("Satellite 6" in c.err)
コード例 #6
0
 def test_cert_v3_cat(self):
     with Capture() as cap:
         command = CatCertCommandStub(certdata.ENTITLEMENT_CERT_V3_0)
         command.main(['will_use_stub'])
     cert_output = cap.out
     self.assert_string_equals(certdata.ENTITLEMENT_CERT_V3_0_OUTPUT,
                               cert_output)
コード例 #7
0
    def test_none_wrap_available_pool_id(self, mget_ents):
        list_command = managercli.ListCommand()

        def create_pool_list(*args, **kwargs):
            return [{
                'productName': 'dummy-name',
                'productId': 'dummy-id',
                'providedProducts': [],
                'id': '888888888888',
                'attributes': [{
                    'name': 'is_virt_only',
                    'value': 'false'
                }],
                'pool_type': 'Some Type',
                'quantity': '4',
                'service_level': '',
                'service_type': '',
                'contractNumber': '5',
                'multi-entitlement': 'false',
                'endDate': '',
                'suggested': '2'
            }]

        mget_ents.return_value = create_pool_list()

        with Capture() as cap:
            list_command.main(['list', '--available'])
        self.assertTrue('888888888888' in cap.out)
コード例 #8
0
 def test_a_msg(self):
     msg = "some message"
     with Capture() as cap:
         try:
             managercli.system_exit(1, msg)
         except SystemExit:
             pass
     self.assertEquals("%s\n" % msg, cap.err)
コード例 #9
0
 def test_list_nonexistant_repos(self):
     data = [Override('x', 'hello', 'world')]
     with Capture() as cap:
         self.cc._list(data, ['x', 'z'])
         output = cap.out
         self.assertTrue(re.search("Nothing is known about 'z'", output))
         self.assertTrue(re.search('Repository: x', output))
         self.assertTrue(re.search('\s+hello:\s+world', output))
コード例 #10
0
 def test_already_registered_to_rhsm(self):
     self._inject_mock_valid_consumer()
     self.engine.options = self.create_options(five_to_six=False)
     with Capture() as c:
         self.assertRaises(SystemExit, self.engine.check_ok_to_proceed,
                           "some_name")
         self.assertTrue("Red Hat Subscription Management" in c.err)
         self.assertTrue("access.redhat.com" in c.err)
コード例 #11
0
 def test_msgs(self):
     msgs = ["a", "b", "c"]
     with Capture() as cap:
         try:
             managercli.system_exit(1, msgs)
         except SystemExit:
             pass
     self.assertEquals("%s\n" % ("\n".join(msgs)), cap.err)
コード例 #12
0
 def test_msg_unicode(self):
     msgs = [u"\u2620 \u2603 \u203D"]
     with Capture() as cap:
         try:
             managercli.system_exit(1, msgs)
         except SystemExit:
             pass
     self.assertEquals("%s\n" % msgs[0].encode("utf8"), cap.err)
コード例 #13
0
 def test_msg_and_exception(self):
     msgs = ["a", ValueError()]
     with Capture() as cap:
         try:
             managercli.system_exit(1, msgs)
         except SystemExit:
             pass
     self.assertEquals("%s\n\n" % msgs[0], cap.err)
コード例 #14
0
    def test_cat_manifest(self):
        catman = CatManifestCommand()
        catman.args = [_build_valid_manifest()]

        with Capture() as cap:
            catman._do_command()

        self.assertEquals("", cap.err)
        self.assert_string_equals(manifestdata.correct_manifest_output, cap.out)
コード例 #15
0
    def test_msg_and_exception_no_str(self):
        class NoStrException(Exception):
            pass

        msgs = ["a", NoStrException()]
        with Capture() as cap:
            try:
                managercli.system_exit(1, msgs)
            except SystemExit:
                pass
        self.assertEquals("%s\n\n" % msgs[0], cap.err)
コード例 #16
0
 def test_list_specific_repos(self):
     data = [
         Override('x', 'hello', 'world'),
         Override('z', 'greetings', 'mars')
     ]
     with Capture() as cap:
         self.cc._list(data, ['x'])
         output = cap.out
         self.assertTrue(re.search('Repository: x', output))
         self.assertTrue(re.search('\s+hello:\s+world', output))
         self.assertFalse(re.search('Repository: z', output))
コード例 #17
0
    def test_handle_collisions(self):
        cmap = {
                '1': {'cert-a-1.pem': ['chan1', 'chan2'], 'cert-b-1.pem': ['chan3']},
                '2': {'cert-x-2.pem': ['chan4', 'chan5']},
                '3': {'cert-m-3.pem': ['chanA'], 'cert-n-3.pem': ['chanB'], 'cert-o-3.pem': ['chanC']}
        }

        with Capture() as cap:
            try:
                self.engine.handle_collisions(cmap)
            except SystemExit, e:
                self.assertEquals(e.code, 1)
            else:
コード例 #18
0
    def test_cat_manifest(self):
        catman = CatManifestCommand()
        parser = OptionParser()
        parser.add_option("--no-content")
        (options, args) = parser.parse_args([])
        catman.options = options
        catman.args = [_build_valid_manifest()]

        with Capture() as cap:
            catman._do_command()

        self.assertEquals("", cap.err)
        self.assert_string_equals(manifestdata.correct_manifest_output, cap.out)
コード例 #19
0
 def test_list_function(self):
     data = [
         Override('x', 'hello', 'world'),
         Override('x', 'blast-off', 'space'),
         Override('y', 'goodbye', 'earth'),
         Override('z', 'greetings', 'mars')
     ]
     with Capture() as cap:
         self.cc._list(data, None)
         output = cap.out
         self.assertTrue(re.search('Repository: x', output))
         self.assertTrue(re.search('\s+hello:\s+world', output))
         self.assertTrue(re.search('\s+blast-off:\s+space', output))
         self.assertTrue(re.search('Repository: y', output))
         self.assertTrue(re.search('\s+goodbye:\s+earth', output))
         self.assertTrue(re.search('Repository: z', output))
         self.assertTrue(re.search('\s+greetings:\s+mars', output))
コード例 #20
0
    def test_get_environment_id_multi_available_bad_name(self):
        def env_list(*args, **kwargs):
            return [{
                "id": "1234",
                "name": "somename"
            }, {
                "id": "5678",
                "name": "othername"
            }]

        with patch('rhsm.connection.UEPConnection',
                   new_callable=StubUEP) as mock_uep:
            mock_uep.getEnvironmentList = env_list
            mock_uep.supports_resource = Mock(return_value=True)
            self.stub_cp_provider.basic_auth_cp = mock_uep

            rc = RegisterCommand()
            rc.options = Mock()
            rc.options.activation_keys = None
            rc._prompt_for_environment = Mock(return_value="not_an_env")

            with nested(Capture(silent=True), self.assertRaises(SystemExit)):
                rc._get_environment_id(mock_uep, 'owner', None)
コード例 #21
0
 def test_date_validate_supported_locales_12_29_2020(self):
     with Capture(silent=True):
         d = datetime(2020, 12, 29, tzinfo=tzlocal())
         self.__date_validate_supported_locales(d)
コード例 #22
0
 def test_product_cert_with_os_name_output(self):
     with Capture() as cap:
         command = StatCertCommandStub(certdata.PRODUCT_CERT_WITH_OS_NAME_V1_0)
         command.main(['will_use_stub'])
     cert_output = cap.out
     self.assert_string_equals(certdata.PRODUCT_CERT_WITH_OS_NAME_V1_0_STAT_OUTPUT, cert_output)
コード例 #23
0
 def test_identity_cert_output(self):
     with Capture() as cap:
         command = CatCertCommandStub(certdata.IDENTITY_CERT)
         command.main(['will_use_stub'])
     cert_output = cap.out
     self.assert_string_equals(certdata.IDENTITY_CERT_OUTPUT, cert_output)
コード例 #24
0
 def test_entitlement_cert_output_includes_content_sets(self):
     with Capture() as cap:
         command = StatCertCommandStub(certdata.ENTITLEMENT_CERT_V3_0)
         command.main(['will_use_stub'])
     cert_output = cap.out
     self.assert_string_equals(certdata.ENTITLEMENT_CERT_V3_0_STAT_OUTPUT, cert_output)
コード例 #25
0
 def test_remove_config_default(self):
     with Capture() as cap:
         self.cc._do_command = self._orig_do_command
         self.cc.main(['--remove', 'rhsm.baseurl'])
     self.assertTrue('The default value for' in cap.out)