def test_clean_up_creation_failed_destroy_others(self, mock):
     self.stderr = sys.stderr
     sys.stderr = StringIO.StringIO()
     failed =  maccli.facade.macfile.clean_up(MOCK_RESPONSE_INSTANCE_LIST_CREATION_FAILED_JSON, MACFILE_ON_FAILURE_DESTROY_OTHERS)
     mock.assert_any_call("id1")
     self.assertTrue(failed)
     sys.stderr = self.stderr
 def test_clean_up_creation_failed_destroy_others(self, mock):
     self.stderr = sys.stderr
     sys.stderr = StringIO.StringIO()
     failed =  maccli.facade.macfile.clean_up(MOCK_RESPONSE_INSTANCE_LIST_CREATION_FAILED_JSON, MACFILE_ON_FAILURE_DESTROY_OTHERS)
     mock.assert_any_call("id1")
     self.assertTrue(failed)
     sys.stderr = self.stderr
 def test_clean_up_configuration_error_destroy_all(self, mock):
     self.stderr = sys.stderr
     sys.stderr = StringIO.StringIO()
     failed =  maccli.facade.macfile.clean_up(MOCK_RESPONSE_INSTANCE_LIST_CONFIGURATION_ERROR_JSON, MACFILE_ON_FAILURE_DESTROY_ALL)
     mock.assert_any_call("id1")
     mock.assert_any_call("id2")
     self.assertTrue(failed)
     sys.stderr = self.stderr
 def test_clean_up_configuration_error_destroy_all(self, mock):
     self.stderr = sys.stderr
     sys.stderr = StringIO.StringIO()
     failed =  maccli.facade.macfile.clean_up(MOCK_RESPONSE_INSTANCE_LIST_CONFIGURATION_ERROR_JSON, MACFILE_ON_FAILURE_DESTROY_ALL)
     mock.assert_any_call("id1")
     mock.assert_any_call("id2")
     self.assertTrue(failed)
     sys.stderr = self.stderr
Beispiel #5
0
    def test_assert_any_call_with_function_spec(self):
        def f(a, b, c, d=None):
            pass

        mock = Mock(spec=f)

        mock(1, b=2, c=3)
        mock(4, 5, c=6, d=7)
        mock.assert_any_call(1, 2, 3)
        mock.assert_any_call(a=1, b=2, c=3)
        mock.assert_any_call(4, 5, 6, 7)
        mock.assert_any_call(a=4, b=5, c=6, d=7)
        self.assertRaises(AssertionError, mock.assert_any_call, 1, b=3, c=2)
        # Expected call doesn't match the spec's signature
        with self.assertRaises(AssertionError) as cm:
            mock.assert_any_call(e=8)
        if hasattr(cm.exception, '__cause__'):
            self.assertIsInstance(cm.exception.__cause__, TypeError)
Beispiel #6
0
    def test_assert_any_call_with_function_spec(self):
        def f(a, b, c, d=None):
            pass

        mock = Mock(spec=f)

        mock(1, b=2, c=3)
        mock(4, 5, c=6, d=7)
        mock.assert_any_call(1, 2, 3)
        mock.assert_any_call(a=1, b=2, c=3)
        mock.assert_any_call(4, 5, 6, 7)
        mock.assert_any_call(a=4, b=5, c=6, d=7)
        self.assertRaises(AssertionError, mock.assert_any_call,
                          1, b=3, c=2)
        # Expected call doesn't match the spec's signature
        with self.assertRaises(AssertionError) as cm:
            mock.assert_any_call(e=8)
        if hasattr(cm.exception, '__cause__'):
            self.assertIsInstance(cm.exception.__cause__, TypeError)
Beispiel #7
0
    def test_assert_any_call(self):
        mock = Mock()
        mock(1, 2)
        mock(a=3)
        mock(1, b=6)

        mock.assert_any_call(1, 2)
        mock.assert_any_call(a=3)
        mock.assert_any_call(1, b=6)

        self.assertRaises(AssertionError, mock.assert_any_call)
        self.assertRaises(AssertionError, mock.assert_any_call, 1, 3)
        self.assertRaises(AssertionError, mock.assert_any_call, a=4)
Beispiel #8
0
    def test_assert_any_call(self):
        mock = Mock()
        mock(1, 2)
        mock(a=3)
        mock(1, b=6)

        mock.assert_any_call(1, 2)
        mock.assert_any_call(a=3)
        mock.assert_any_call(1, b=6)

        self.assertRaises(AssertionError, mock.assert_any_call)
        self.assertRaises(AssertionError, mock.assert_any_call, 1, 3)
        self.assertRaises(AssertionError, mock.assert_any_call, a=4)
Beispiel #9
0
    def test_assert_any_call(self):
        for mock in Mock(), mocksignature(lambda *args, **kwargs: None):
            mock(1, 2)
            mock(a=3)
            mock(1, b=6)

            mock.assert_any_call(1, 2)
            mock.assert_any_call(a=3)
            mock.assert_any_call(1, b=6)

            self.assertRaises(AssertionError, mock.assert_any_call)
            self.assertRaises(AssertionError, mock.assert_any_call, 1, 3)
            self.assertRaises(AssertionError, mock.assert_any_call, a=4)
Beispiel #10
0
    def test_assert_any_call(self):
        for mock in Mock(), mocksignature(lambda *args, **kwargs: None):
            mock(1, 2)
            mock(a=3)
            mock(1, b=6)

            mock.assert_any_call(1, 2)
            mock.assert_any_call(a=3)
            mock.assert_any_call(1, b=6)

            self.assertRaises(
                AssertionError,
                mock.assert_any_call
            )
            self.assertRaises(
                AssertionError,
                mock.assert_any_call,
                1, 3
            )
            self.assertRaises(
                AssertionError,
                mock.assert_any_call,
                a=4
            )