Пример #1
0
def add_currencies():
    ccys = [
        Currency(name="US Dollar", code="USD"),
        Currency(name="Bitcoin", code="BTC")
    ]

    [db.session.add(ccy) for ccy in ccys]
    db.session.commit()
Пример #2
0
def test_bad_formed_ccy():

    with pytest.raises(ValidateError):
        ccy = Currency(code=12345, name="US Dollar")

    with pytest.raises(ValidateError):
        ccy = Currency(code="USD", name=12345)

    with pytest.raises(ValidateError):
        ccy = Currency(code=None, name=12345)

    with pytest.raises(ValidateError):
        ccy = Currency(code="USD", name=None)
Пример #3
0
def model_objects():
    objects = {
        'u1': User(id=1, username="******", email="*****@*****.**"),
        'u2': User(id=2, username="******", email="*****@*****.**"),
        'u3': User(id=3, username="******", email="*****@*****.**"),
        'u4': User(id=4, username="******", email="*****@*****.**"),
        'usd': Currency(id=1, code="USD", name="US Dollar"),
        'btc': Currency(id=2, code="BTC", name="Bitcoin"),
        'acct1': Account(id=1, ccy_id=1, name="USD Credits"),
        'acct2': Account(id=2, ccy_id=1, name="USD Debits"),
        'acct3': Account(id=3, ccy_id=2, name="BTC Wallet"),
    }

    return objects
Пример #4
0
def test_insert_ccy():

    ccy = Currency(code="USD", name="US Dollar")
    db.session.add(ccy)
    db.session.commit()

    retrieved_ccy = db.session.query(Currency).one()

    assert retrieved_ccy == ccy
Пример #5
0
def test_db_project(db):
    proj_name = "Test Proj"
    proj_desc = "A project for testing"
    proj_goal = 100
    ccy_name = "USD Dollar"
    ccy_code = "USD"
    acct_name = "{}_{}_acct".format(proj_name, ccy_code)

    ccy = Currency(name=ccy_name, code=ccy_code)
    account = Account(name=acct_name, ccy=ccy)
    proj = Project(name=proj_name, desc=proj_desc, goal=proj_goal)
    proj.accounts = [account]

    db.session.add(proj)
    db.session.commit()
Пример #6
0
def test_view_new_project_post(testapp, db):
    app = testapp

    project_name = "Test Project"
    ccy_code = "USD"
    ccy_name = "US Dollar"
    amt = 4000
    proj_desc = "A test project"

    ccy = Currency(code=ccy_code, name=ccy_name)
    db.session.add(ccy)

    db.session.commit()

    data = {
        'goal': amt,
        'ccy': ccy_code,
        'desc': proj_desc,
        'project_name': project_name,
    }
    url = "/new/project"
    response = app.post(url, data=data)

    project = db.session.query(Project).filter_by(name=project_name).one()
    assert project is not None
    assert project.name == project_name
    assert project.desc == proj_desc
    assert project.goal == amt

    accounts = project.accounts
    assert accounts is not None
    assert len(accounts) == 1

    acct = accounts[0]
    assert acct.name == "{}_{}_acct".format(project_name, ccy_code)

    ccy = acct.ccy
    assert ccy.code == ccy_code
    assert ccy.name == ccy_name

    assert response.status_code == 200
def init():
    '''Adds the initial currency, account, and project for the General Fund.'''

    ccy = Currency(code="USD", name="US Dollar")
    acct = Account(name="General Fund Account", ccy=ccy)
    project = Project(name="General Fund",
                      desc="Noisebridge's account of record",
                      goal=0,
                      accounts=[acct])

    session = create_session()

    donate_config = DonateConfiguration(key="INIT",
                                        type="string",
                                        value="true")
    try:
        session.add(project)  # Includes the ccy and acct of the project
        session.add(donate_config)
        session.commit()
    except Exception as e:
        session.rollback()
        raise e
Пример #8
0
def test_new_ccy():
    # app = create_app(TestConfig)
    ccy = Currency(code="USD", name="US Dollar")

    assert ccy.code == "USD"
    assert ccy.name == "US Dollar"
Пример #9
0
def test_new_ccy():
    ccy = Currency(code="USD", name="US Dollar")

    assert ccy.code == "USD"
    assert ccy.name == "US Dollar"