Ejemplo n.º 1
0
def test_bucket_trades_for_profile():
    """
    Tests InvestmentBucket.trades_for_profile()
    """
    user1 = User.objects.create(username='******', password="******")
    user2 = User.objects.create(username='******', password="******")
    InvestmentBucket(name="B1", owner=user1.profile, public=False,
                     available=1).save()
    InvestmentBucket(name="B2", owner=user1.profile, public=True,
                     available=1).save()
    InvestmentBucket(name="B3", owner=user1.profile, public=False,
                     available=1).save()
    InvestmentBucket(name="B4", owner=user2.profile, public=False,
                     available=1).save()
    assert InvestmentBucket.accessible_buckets(user1.profile).count() == 3
    assert InvestmentBucket.accessible_buckets(user2.profile).count() == 2
Ejemplo n.º 2
0
    def resolve_invest_suggestions(_data, info, **_args):
        """
        Returns a list of buckets that the User can invest in.
        (see :py:meth:`stocks.models.InvestmentBucket.available_buckets`)

        :param info: Information about the user to check which recommendations
            are best for the user.
        :type info: Graphene Request Info.
        :returns: :py:class:`django.db.models.query.QuerySet` of
            :py:class:`stocks.models.InvestmentBucket`
        """
        return InvestmentBucket.accessible_buckets(info.context.user.profile)