Exemplo n.º 1
0
 def test_parsing_with_four_character_symbol(self):
     coin = Coin.create(name='foocoin', symbol='DASH')
     ping('DASH')
     dash = Coin.get(Coin.symbol == 'DASH')
     ticker = Ticker.get(Ticker.coin == dash)
     self.assertEqual(ticker.price, Decimal('56.12345678'))
     self.assertEqual(ticker.price_change_day_pct, Decimal('-1.23456789'))
Exemplo n.º 2
0
 def test_price_alerts(self):
     os.environ['NOMICS_BASE_URL'] = 'foo'
     profile = Profile.create(username='******',
                              hashed_password='******')
     coin = Coin.create(name='foocoin', symbol='FOO')
     alert = PriceAlert.create(
         profile=profile,
         above=True,
         coin=coin,
         strike_price=Decimal(0.1),
     )
     alert = PriceAlert.create(
         profile=profile,
         above=False,
         coin=coin,
         strike_price=Decimal(0.1),
     )
     ping('FOO')
     self.assertEqual(1, Notification.select().count())
     # ok, the line below throws an exception which causes all other tests to fail
     # as tearDown is not called and because db is in inconsistent state
     notif = Notification.get(Notification.profile == profile)
Exemplo n.º 3
0
def up(db):
    with db.atomic():
        migrator = PostgresqlMigrator(db)
        db.bind(MODELS, bind_refs=False, bind_backrefs=False)
        db.create_tables(MODELS)
        if Coin.get_or_none(Coin.id == 1) is None:
            Coin.create(name='Bitcoin', symbol='BTC')
            Coin.create(name='Ethereum', symbol='ETH')
            Coin.create(name='Litecoin', symbol='LTC')
            Coin.create(name='Coin 3', symbol='CO3')
            Coin.create(name='Coin 4', symbol='CO4')
            Coin.create(name='Coin 5', symbol='CO5')

        global_indef = Game.create(name='Global Indefinite',
                                   starting_cash=10000.00,
                                   shareable_link='INDEF',
                                   shareable_code='INDEF',
                                   ends_at=None)

        # insert achievements into database
        Achievement.create(
            name="Win", description="Finish in first place in a private game")
        Achievement.create(
            name="Double net worth",
            description="Achieved by doubling your net worth in a game")
        Achievement.create(name="Identity Crisis",
                           description="Change your username")

        # insert goals into database
        Goal.create(name="Entrepreneur", description="Create a private game")

        all_coins = Coin.select()
        for coin in all_coins:
            GameCoin.create(game=global_indef, coin=coin)

        global_timed = Game.create(name='Global Timed',
                                   starting_cash=10000.00,
                                   shareable_link='TIMED',
                                   shareable_code='TIMED',
                                   ends_at=datetime.utcnow() +
                                   timedelta(minutes=1))
        # CHANGEME for devel purposes, making it 1 min for now
        GameCoin.create(game=global_timed, coin=Coin.get())

        # from auth.services import register
        hashed = bcrypt.hashpw("admin".encode(), bcrypt.gensalt()).decode()
        admin = Profile.create(username="******",
                               hashed_password=hashed,
                               is_admin=True)
        # Required so that admin can still view graphs in the landing page
        GameProfile.create(profile=admin, game=global_indef, cash=0.0)