# Path: actors/internal/factory.py
# class ActorFactory(object):
# 
#     def __init__(self, system, supervisor):
#         """
#         :param system:
#         :type system: :class:`ActorSystem`
# 
#         :param supervisor:
#         :type supervisor: :class:`InternalRef`
#         """
#         self._system = system
#         self._supervisor = supervisor
# 
#     def actor_of(self, cls=None, behaviour=None, dispatcher=None):
#         if cls:
#             factory = cls
#         elif behaviour:
#             factory = _actor_from_behaviour(behaviour)
#         else:
#             raise ValueError()
# 
#         if dispatcher is None:
#             dispatcher = self._system._system_dispatcher
# 
#         from actors.internal.cell import Cell
#         cell = Cell(factory, dispatcher=dispatcher, system=self._system,
#                          parent=self._supervisor)
# 
#         internal_ref = InternalRef(cell)
#         self._supervisor.send_system_message(Supervise(internal_ref))
#         internal_ref.send_system_message(Start)
# 
#         return ActorRef(cell)
# 
# Path: actors/internal/messages.py

# 
# Path: actors/ref.py
# class InternalRef(ActorRef):
# 
#     def __init__(self, cell):
#         super(InternalRef, self).__init__(cell)
# 
#     def send_system_message(self, message):
#         self._cell.send_system_message(message)
# 
# Path: tests/mock_compat.py



import pytest
from actors.internal.factory import ActorFactory
from actors.internal.messages import Supervise
from actors.ref import InternalRef
from tests.mock_compat import Mock
# -*- coding: utf-8 -*-
#
# Copyright 2015 Thomas Amland
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



def test_actor_of_send_supervise_message_to_parent_on_creation():
    supervisor = Mock(spec_set=InternalRef)
    factory = ActorFactory(Mock(), supervisor)

# Path: actors/internal/factory.py
# class ActorFactory(object):
# 
#     def __init__(self, system, supervisor):
#         """
#         :param system:
#         :type system: :class:`ActorSystem`
# 
#         :param supervisor:
#         :type supervisor: :class:`InternalRef`
#         """
#         self._system = system
#         self._supervisor = supervisor
# 
#     def actor_of(self, cls=None, behaviour=None, dispatcher=None):
#         if cls:
#             factory = cls
#         elif behaviour:
#             factory = _actor_from_behaviour(behaviour)
#         else:
#             raise ValueError()
# 
#         if dispatcher is None:
#             dispatcher = self._system._system_dispatcher
# 
#         from actors.internal.cell import Cell
#         cell = Cell(factory, dispatcher=dispatcher, system=self._system,
#                          parent=self._supervisor)
# 
#         internal_ref = InternalRef(cell)
#         self._supervisor.send_system_message(Supervise(internal_ref))
#         internal_ref.send_system_message(Start)
# 
#         return ActorRef(cell)
# 
# Path: actors/internal/messages.py

# 
# Path: actors/ref.py
# class InternalRef(ActorRef):
# 
#     def __init__(self, cell):
#         super(InternalRef, self).__init__(cell)
# 
#     def send_system_message(self, message):
#         self._cell.send_system_message(message)
# 
# Path: tests/mock_compat.py



# Path: tests/test_factory.py
import pytest
from actors.internal.factory import ActorFactory
from actors.internal.messages import Supervise
from actors.ref import InternalRef
from tests.mock_compat import Mock

# -*- coding: utf-8 -*-
#
# Copyright 2015 Thomas Amland
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



def test_actor_of_send_supervise_message_to_parent_on_creation():
    supervisor = Mock(spec_set=InternalRef)
    factory = ActorFactory(Mock(), supervisor)

    factory.actor_of(Mock())