Esempio n. 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
Esempio n. 2
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
Esempio n. 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)
Esempio n. 4
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)
Esempio n. 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())
Esempio n. 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')
Esempio n. 7
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())
Esempio n. 8
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')