コード例 #1
0
def test_create_dictionary_key():
    """Try creating a unique key from a dict.
    """

    values = [dict(foo=10), dict(foo2=datetime.datetime.now())]

    for value in values:
        assert len(utils.create_dictionary_key(value)) == 40
コード例 #2
0
ファイル: test_utils.py プロジェクト: xethorn/garcon
def test_create_dictionary_key():
    """Try creating a unique key from a dict.
    """

    values = [
        dict(foo=10),
        dict(foo2=datetime.datetime.now())]

    for value in values:
        assert len(utils.create_dictionary_key(value)) == 40
コード例 #3
0
    def id(self):
        """Generate the id of the activity.

        The id is crutial (not just important): it allows to indentify the
        state the activity instance in the event history (if it has failed,
        been executed, or marked as completed.)

        Return:
            str: composed of the activity name (task list), and the activity
                id.
        """

        if not self.local_context:
            activity_id = 1
        else:
            activity_id = utils.create_dictionary_key(self.local_context)

        return '{name}-{id}'.format(name=self.activity_name, id=activity_id)
コード例 #4
0
ファイル: activity.py プロジェクト: pombredanne/garcon
    def id(self):
        """Generate the id of the activity.

        The id is crutial (not just important): it allows to indentify the
        state the activity instance in the event history (if it has failed,
        been executed, or marked as completed.)

        Return:
            str: composed of the activity name (task list), and the activity
                id.
        """

        if not self.local_context:
            activity_id = 1
        else:
            activity_id = utils.create_dictionary_key(self.local_context)

        return "{name}-{id}".format(name=self.activity_name, id=activity_id)
コード例 #5
0
def test_create_dictionary_key_with_empty_dict():
    """Try creating a key using an empty dictionary.
    """

    with pytest.raises(ValueError):
        utils.create_dictionary_key(dict())
コード例 #6
0
def test_create_dictionary_key_with_string():
    """Try creating a key using a string instead of a dict.
    """

    with pytest.raises(TypeError):
        utils.create_dictionary_key('something')
コード例 #7
0
ファイル: test_utils.py プロジェクト: xethorn/garcon
def test_create_dictionary_key_with_empty_dict():
    """Try creating a key using an empty dictionary.
    """

    with pytest.raises(ValueError):
        utils.create_dictionary_key(dict())
コード例 #8
0
ファイル: test_utils.py プロジェクト: xethorn/garcon
def test_create_dictionary_key_with_string():
    """Try creating a key using a string instead of a dict.
    """

    with pytest.raises(TypeError):
        utils.create_dictionary_key('something')