コード例 #1
0
    def test_happy_path(self, ctx, mock_device_repository: MagicMock,
                        device_manager: DeviceManager):
        # When...
        device_manager.delete(ctx, TEST_MAC_ADDRESS1)

        # Expect...
        mock_device_repository.delete_device.assert_called_once_with(
            ctx, mac_address=TEST_MAC_ADDRESS1)
コード例 #2
0
    def test_device_not_found(self, ctx, mock_device_repository: MagicMock,
                              device_manager: DeviceManager):
        # Given
        mock_device_repository.delete_device = MagicMock(
            side_effect=DeviceNotFoundError)

        # When...
        with raises(DeviceNotFoundError):
            device_manager.delete(ctx, TEST_MAC_ADDRESS1)

        # Expect...
        mock_device_repository.delete_device.assert_called_once_with(
            ctx, mac_address=TEST_MAC_ADDRESS1)