Beispiel #1
0
 def test_feature_run_order_install(self):
     """ A feature install should have it's methods run in the proper order """
     with patch("sprinter.formula.base.FormulaBase", new=create_mock_formulabase()) as formulabase:
         with MockEnvironment(test_source, test_target, mock_formulabase=formulabase) as environment:
             environment.install()
             eq_(
                 formulabase().method_calls,
                 [call.should_run(), call.validate(), call.resolve(), call.prompt(), call.sync()],
             )
 def test_feature_run_order_install(self, mock_feature):
     """ A feature install should have it's methods run in the proper order """
     with patch('sprinter.core.featuredict.Feature', new=lambda *args: mock_feature) as mock_call:
         with MockEnvironment(test_source, test_target) as environment:
             environment.install()
             eq_(mock_call().method_calls, [call.should_run(),
                                               call.validate(),
                                               call.resolve(),
                                               call.prompt(),
                                               call.sync()])
Beispiel #3
0
 def test_feature_run_order_deactivate(self):
     """ A feature deactivate should have it's methods run in the proper order """
     with patch("sprinter.formula.base.FormulaBase", new=create_mock_formulabase()) as formulabase:
         with MockEnvironment(test_source, test_target, mock_formulabase=formulabase) as environment:
             environment.directory = Mock(spec=environment.directory)
             environment.directory.new = False
             environment.deactivate()
             eq_(
                 formulabase().method_calls,
                 [call.should_run(), call.validate(), call.resolve(), call.prompt(), call.deactivate()],
             )
 def test_feature_run_order_deactivate(self, mock_feature):
     """ A feature deactivate should have it's methods run in the proper order """
     with patch('sprinter.core.featuredict.Feature', new=lambda *args: mock_feature) as mock_call:
         with MockEnvironment(test_source, test_target) as environment:
             environment.directory = Mock(spec=environment.directory)
             environment.directory.new = False
             environment.deactivate()
             eq_(mock_call().method_calls, [call.should_run(),
                                            call.validate(),
                                            call.resolve(),
                                            call.prompt(),
                                            call.deactivate()])
Beispiel #5
0
    def test_corba_context_is_not_none(self):
        mock_context = Mock()
        corba_obj = CorbaNameServiceClient()
        corba_obj.context = mock_context

        with patch('pyfco.name_service.installTransientExceptionHandler', autospec=True):
            with patch.object(CosNaming, "NameComponent") as mock_name_component:
                corba_obj.get_object("Logger", "ccRegTest.Logger")
        self.assertEqual(mock_context.mock_calls, [
            call.resolve([mock_name_component.return_value, mock_name_component.return_value]),
            call.resolve()._narrow('ccRegTest.Logger')
        ])
        if six.PY2:  # pragma: no cover
            self.assertEqual(mock_name_component.mock_calls, [
                call('fred'.encode(), 'context'.encode()),
                call('Logger'.encode(), 'Object'.encode())
            ])
        else:  # pragma: no cover
            self.assertEqual(mock_name_component.mock_calls, [
                call('fred', 'context'),
                call('Logger', 'Object')
            ])
Beispiel #6
0
 def test_feature_run_order_install(self):
     """ A feature install should have it's methods run in the proper order """
     with patch('sprinter.formula.base.FormulaBase',
                new=create_mock_formulabase()) as formulabase:
         with MockEnvironment(test_source,
                              test_target,
                              mock_formulabase=formulabase) as environment:
             environment.install()
             eq_(formulabase().method_calls, [
                 call.should_run(),
                 call.validate(),
                 call.resolve(),
                 call.prompt(),
                 call.sync()
             ])
Beispiel #7
0
 def test_feature_run_order_activate(self):
     """ A feature should have it's methods run in the proper order """
     with patch('sprinter.formula.base.FormulaBase',
                new=create_mock_formulabase()) as formulabase:
         with MockEnvironment(test_source,
                              test_target,
                              mock_formulabase=formulabase) as environment:
             environment.directory = Mock(spec=environment.directory)
             environment.directory.new = False
             environment.activate()
             eq_(formulabase().method_calls, [
                 call.should_run(),
                 call.validate(),
                 call.resolve(),
                 call.prompt(),
                 call.activate()
             ])
 def test_feature_run_order_install(self):
     """ A feature install should have it's methods run in the proper order """
     environment = create_mock_environment(
         target_config=test_target
     )
     mock_formulabase = Mock(spec=FormulaBase)
     mock_formulabase.resolve.return_value = None
     mock_formulabase.validate.return_value = None
     mock_formulabase.prompt.return_value = None
     mock_formulabase.sync.return_value = None
     environment.formula_dict['sprinter.formulabase'] = Mock(return_value=mock_formulabase)
     environment.install()
     tools.eq_(mock_formulabase.method_calls, [call.should_run(),
                                               call.validate(),
                                               call.resolve(),
                                               call.prompt(),
                                               call.sync()])
 def test_feature_run_order_activate(self):
     """ A feature should have it's methods run in the proper order """
     environment = create_mock_environment(
         source_config=test_source,
         installed=True
     )
     mock_formulabase = Mock(spec=FormulaBase)
     mock_formulabase.resolve.return_value = None
     mock_formulabase.validate.return_value = None
     mock_formulabase.prompt.return_value = None
     mock_formulabase.activate.return_value = None
     environment.formula_dict['sprinter.formulabase'] = Mock(return_value=mock_formulabase)
     environment.activate()
     tools.eq_(mock_formulabase.method_calls, [call.should_run(),
                                               call.validate(),
                                               call.resolve(),
                                               call.prompt(),
                                               call.activate()])