def test_get_actor_logger(create_logger):
    log_mock = Mock()
    create_logger.return_value = log_mock
    log = calvinlogger.get_actor_logger("abc")

    assert create_logger.called
    assert log == log_mock.getChild("abc")
Пример #2
0
def test_get_actor_logger(create_logger):
    log_mock = Mock()
    create_logger.return_value = log_mock
    log = calvinlogger.get_actor_logger("abc")

    assert create_logger.called
    assert log == log_mock.getChild("abc")
Пример #3
0
# 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.

from calvin.utilities.calvinlogger import get_actor_logger
from calvin.actor.actor import Actor, manage, condition, calvinlib

_log = get_actor_logger(__name__)


class RandomNumber(Actor):
    """
    Produce random number (floating point) in range [lower ... upper)

    Inputs:
      trigger : Any token
    Outputs:
      number : Random number in range [lower ... upper)
    """
    @manage(['lower', 'upper'])
    def init(self, lower, upper):
        self.lower = lower
        self.upper = upper
Пример #4
0
# 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.

from calvin.utilities.calvinlogger import get_actor_logger
from calvin.actor.actor import Actor, manage, condition, calvinlib

_log = get_actor_logger(__name__)


class RandomInteger(Actor):
    """
    Produce random integer in range [lower ... upper-1]

    Inputs:
      trigger : Any token
    Outputs:
      integer : Random integer in range [lower ... upper-1]
    """

    @manage(['lower', 'upper'])
    def init(self, lower, upper):
        self.lower = lower