Esempio n. 1
0
def new_client():
    client = Client.create(ssn=SocialSecurityNumber(345456567),
                           last_name=LastName("test"),
                           first_name=FirstName("more"),
                           birthdate=Birthdate('23/04/1993'),
                           operation_id=UniqueID())
    client.add_account(UniqueID(), UniqueID())
    return client
Esempio n. 2
0
 def wrapped(target_id):
     if client_id == target_id:
         client_created = ClientCreated(
             operation_id=str(UniqueID()),
             client_id=client_id.value,
             ssn=SocialSecurityNumber(123456789).value,
             first_name=FirstName('asd').value,
             last_name=LastName('asd').value,
             birthdate=Birthdate('22/01/1900').value)
         client = Client(EventStream([client_created]))
         return client
     return None
Esempio n. 3
0
def test_birthday_throws_app_exception_when_invalid_data_but_right_format():
    with pytest.raises(ValueError) as e:
        Birthdate('50/02/1998')
Esempio n. 4
0
def test_birthday_create_from_string_in_right_format():
    Birthdate('27/02/2017')
Esempio n. 5
0
def test_birthdate_has_value_getter():
    b = Birthdate('27/02/2017')
    assert b.value == '27/02/2017'
Esempio n. 6
0
def test_birthday_has_day_getter():
    b = Birthdate('27/02/2017')
    assert b.day == 27
Esempio n. 7
0
def test_birthday_has_month_getter():
    b = Birthdate('27/02/2017')
    assert b.month == 2
Esempio n. 8
0
def test_birthday_has_year_getter():
    b = Birthdate('27/02/2017')
    assert b.year == 2017
Esempio n. 9
0
def db(app, account_id: UniqueID, client_id: UniqueID, account_name: str):
    with app.app_context():
        event_store_db.create_all()

        client_create_operation_id = UniqueID()
        client_created_event = ClientCreated(
            client_id=str(client_id),
            ssn=SocialSecurityNumber(123456789).value,
            operation_id=str(client_create_operation_id),
            first_name=FirstName('test').value,
            last_name=LastName('test').value,
            birthdate=Birthdate('27/02/1998').value)
        account_added_to_client = AccountAddedToClient(
            client_id=str(client_id),
            account_id=str(account_id),
            operation_id=str(client_create_operation_id),
            account_name=account_name)

        account_create_operation_id = UniqueID()
        account_created_event = AccountCreated(
            operation_id=account_create_operation_id.value,
            client_id=str(client_id),
            account_id=str(account_id),
            account_name=account_name)
        account_credit_event = AccountCredited(
            operation_id=account_create_operation_id.value,
            dollars=23,
            cents=0,
            account_id=str(account_id))

        client_aggregate = AggregateModel(uuid=str(client_id),
                                          version=AGGREGATE_VERSION)
        client_created_db_event = EventModel(
            uuid=str(UniqueID()),
            aggregate_uuid=str(client_id),
            name=client_created_event.__class__.__name__,
            data=asdict(client_created_event))
        account_added_to_client_db_event = EventModel(
            uuid=str(UniqueID()),
            aggregate_uuid=str(client_id),
            name=account_added_to_client.__class__.__name__,
            data=asdict(account_added_to_client))

        account_aggregate = AggregateModel(uuid=str(account_id),
                                           version=AGGREGATE_VERSION)
        account_created_db_event = EventModel(
            uuid=str(UniqueID()),
            aggregate_uuid=account_id.value,
            name=account_created_event.__class__.__name__,
            data=asdict(account_created_event))
        account_credited_db_event = EventModel(
            uuid=str(UniqueID()),
            aggregate_uuid=account_id.value,
            name=account_credit_event.__class__.__name__,
            data=asdict(account_credit_event))

        event_store_db.session.add(client_aggregate)
        event_store_db.session.add(account_aggregate)
        event_store_db.session.flush()
        event_store_db.session.add(client_created_db_event)
        event_store_db.session.add(account_added_to_client_db_event)
        event_store_db.session.add(account_created_db_event)
        event_store_db.session.add(account_credited_db_event)
        event_store_db.session.commit()

        yield event_store_db  # this is the object that the tests use

        event_store_db.drop_all()
Esempio n. 10
0
def new_client():
    return Client.create(first_name=FirstName("test"),
                         last_name=LastName("trt"),
                         birthdate=Birthdate('27/02/1998'),
                         ssn=SocialSecurityNumber(123456789),
                         operation_id=UniqueID())