Exemple #1
0
def test_icon_property(question):
    action = Action(
        verb=Verbs.ADD.value,
        obj=question,
    )

    assert action.icon == 'star'

    configure_type(
        'thing',
        (question._meta.app_label, question._meta.model_name)
    )
    assert action.icon == 'star'

    configure_icon('plus', verb=Verbs.ADD)
    assert action.icon == 'plus'

    other_action = Action(
        verb=Verbs.CREATE.value,
        obj=question
    )
    assert other_action.icon == 'star'

    configure_icon('circle', type='thing')
    assert action.icon == 'plus'
    assert other_action.icon == 'circle'
Exemple #2
0
def test_action_string_without_actor(question_factory):
    question = question_factory()
    action = Action(
        verb=Verbs.CREATE.value,
        obj=question,
    )
    str_expected = 'create {}'.format(question, )
    assert str(action) == str_expected
Exemple #3
0
def test_action_string_with_target(question_factory):
    question = question_factory()
    project = question.module.project
    action = Action(
        verb=Verbs.ADD.value,
        obj=question,
        target=project,
    )
    str_expected = 'add {} to {}'.format(question, project)
    assert str(action) == str_expected
Exemple #4
0
def test_type_property(question):
    action = Action(
        verb=Verbs.ADD.value,
        obj=question,
    )

    assert action.type == 'unknown'

    configure_type('thing',
                   (question._meta.app_label, question._meta.model_name))
    assert action.type == 'thing'

    configure_type('thong',
                   (question._meta.app_label, question._meta.model_name))
    assert action.type == 'thong'
Exemple #5
0
def test_action_create(question_factory):
    question = question_factory()
    project = question.module.project
    now = timezone.now()
    with freeze_time(now):
        action = Action(actor=question.creator,
                        verb=Verbs.ADD.value,
                        obj=question,
                        target=project,
                        description='description')
    assert action.actor == question.creator
    assert action.verb == Verbs.ADD.value
    assert action.obj == question
    assert action.target == project
    assert action.timestamp == now
    assert action.public is True
    assert action.description == 'description'