<gh_stars>1-10
from accounts.cqrs import app
from cq.contrib.django.models import Event
import inspect
import pytest


@pytest.mark.django_db
def test_register(mocker):
    mocker.patch('accounts.cqrs.make_password', lambda p: '<PASSWORD>')
    mocker.patch.object(app, 'genuuid', lambda: 'ACTIVATION_TOKEN')
    app.register(email='<EMAIL>', password='<PASSWORD>')

    assert Event.objects.count() == 1
    event = Event.objects.all().get()

    assert event.revision == 2


@pytest.mark.django_db
def test_iter_all_events():
    events = [
        app.register(email='<EMAIL>', password='<PASSWORD>'),
        app.register(email='<EMAIL>', password='<PASSWORD>'),
        app.register(email='<EMAIL>', password='<PASSWORD>'),
    ]

    assert inspect.isgenerator(app.storage.iter_all_events()) is True
    assert list(app.storage.iter_all_events()) == events

from accounts.cqrs import app
from cq.contrib.django.models import Event
import inspect
import pytest


@pytest.mark.django_db
def test_register(mocker):
    mocker.patch('accounts.cqrs.make_password', lambda p: '<PASSWORD>')
    mocker.patch.object(app, 'genuuid', lambda: 'ACTIVATION_TOKEN')
    app.register(email='<EMAIL>', password='<PASSWORD>')

    assert Event.objects.count() == 1
    event = Event.objects.all().get()

    assert event.revision == 2


@pytest.mark.django_db
def test_iter_all_events():
    events = [
        app.register(email='<EMAIL>', password='<PASSWORD>'),
        app.register(email='<EMAIL>', password='<PASSWORD>'),
        app.register(email='<EMAIL>', password='<PASSWORD>'),
    ]

    assert inspect.isgenerator(app.storage.iter_all_events()) is True
    assert list(app.storage.iter_all_events()) == events