Exemple #1
0
def candidate_fixture(user_fixture, culture_fixture, candidate_source_fixture,
                      request):
    candidate_attrs = dict(first_name=random_word(4),
                           last_name=random_word(6),
                           formatted_name=random_word(10),
                           is_archived=0,
                           is_mobile_hidden=0,
                           added_time=datetime.today(),
                           user_id=user_fixture.id,
                           domain_can_read=1,
                           domain_can_write=1,
                           source_id=candidate_source_fixture.id,
                           source_product_id=2,
                           objective=random_word(6),
                           culture_id=culture_fixture.id,
                           is_dirty=0)
    candidate, created = get_or_create(db.session,
                                       Candidate,
                                       defaults=None,
                                       **candidate_attrs)
    if created:
        db.session.add(candidate)
        db.session.commit()

    @require_integrity(database_object=db)
    def fin():
        db.session.delete(candidate)
        db.session.commit()

    request.addfinalizer(fin)
    return candidate
Exemple #2
0
def culture_fixture(request):
    culture_attrs = dict(description=random_word(12), code=random_word(5))
    culture, created = get_or_create(db.session,
                                     Culture,
                                     defaults=None,
                                     **culture_attrs)
    if created:
        db.session.add(culture)
        db.session.commit()

    @require_integrity(database_object=db)
    def fin():
        db.session.delete(culture)
        db.session.commit()

    request.addfinalizer(fin)
    return culture
Exemple #3
0
def org_fixture(request):
    org_attrs = dict(
        name='Rocket League All Stars - {}'.format(random_word(8)))
    org, created = get_or_create(db.session,
                                 Organization,
                                 defaults=None,
                                 **org_attrs)
    if created:
        db.session.add(org)
        db.session.commit()

    @require_integrity(database_object=db)
    def fin():
        db.session.delete(org)
        db.session.commit()

    request.addfinalizer(fin)
    return org
Exemple #4
0
def client_fixture(request):
    client_attrs = dict(client_id=random_word(30),
                        client_secret=random_word(12))
    client, created = get_or_create(db.session,
                                    Client,
                                    defaults=None,
                                    **client_attrs)
    if created:
        db.session.add(client)
        db.session.commit()

    @require_integrity(database_object=db)
    def fin():
        db.session.delete(client)
        db.session.commit()

    request.addfinalizer(fin)
    return client
Exemple #5
0
def user_fixture(domain_fixture, request):
    user_attrs = dict(domain_id=domain_fixture.id,
                      first_name='Jamtry',
                      last_name='Jonas',
                      password=random_word(12),
                      email=random_word(7),
                      added_time=datetime(2050, 4, 26))
    user, created = get_or_create(db.session,
                                  User,
                                  defaults=None,
                                  **user_attrs)
    if created:
        db.session.add(user)
        db.session.commit()

    @require_integrity(database_object=db)
    def fin():
        db.session.delete(user)
        db.session.commit()

    request.addfinalizer(fin)
    return user
Exemple #6
0
def token_fixture(client_fixture, user_fixture, request):
    token_attrs = dict(client_id=client_fixture.client_id,
                       user_id=user_fixture.id,
                       token_type='bearer',
                       access_token=random_word(26),
                       refresh_token=random_word(26),
                       expires=datetime(2050, 4, 26))
    token, created = get_or_create(db.session,
                                   Token,
                                   defaults=None,
                                   **token_attrs)
    if created:
        db.session.add(token)
        db.session.commit()

    @require_integrity(database_object=db)
    def fin():
        db.session.delete(token)
        db.session.commit()

    request.addfinalizer(fin)
    return token
Exemple #7
0
def domain_fixture(org_fixture, culture_fixture, request):
    domain_attrs = dict(name=random_word(10).format(),
                        usage_limitation=-1,
                        added_time=datetime.today(),
                        organization_id=org_fixture.id,
                        is_fair_check_on=0,
                        is_active=1,
                        default_culture_id=culture_fixture.id,
                        expiration=datetime.utcnow().replace(year=2015))
    domain, created = get_or_create(db.session,
                                    Domain,
                                    defaults=None,
                                    **domain_attrs)
    if created:
        db.session.add(domain)
        db.session.commit()

    @require_integrity(database_object=db)
    def fin():
        db.session.delete(domain)
        db.session.commit()

    request.addfinalizer(fin)
    return domain