Skip to content

Commit

Permalink
fix(tests): resolve import error
Browse files Browse the repository at this point in the history
  • Loading branch information
chibie committed Sep 24, 2020
1 parent 097d6da commit b69604f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions app/marketing/management/commands/new_bounties_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

THROTTLE_S = 0.005


class Command(BaseCommand):

help = 'sends new_bounty_daily _emails'
Expand Down Expand Up @@ -63,15 +64,16 @@ def handle(self, *args, **options):
# stats
speed = counter_total / (time.time() - start_time)
ETA = round((total_count - counter_total) / speed / 3600, 1)
print(f"{counter_sent} sent/{counter_total} enabled/ {total_count} total, {round(speed, 2)}/s, ETA:{ETA}h, working on {to_email} ")
print(
f"{counter_sent} sent/{counter_total} enabled/ {total_count} total, {round(speed, 2)}/s, ETA:{ETA}h, working on {to_email} ")

# send
did_send = new_bounty_daily(es.pk)
if did_send:
counter_sent += 1

time.sleep(THROTTLE_S)

except Exception as e:
logging.exception(e)
print(e)
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

import pytest
from dashboard.models import Bounty, Profile
from marketing.management.commands.new_bounties_email import get_bounties_for_keywords
from marketing.mails import get_bounties_for_keywords
from marketing.models import Keyword
from test_plus.test import TestCase


@pytest.mark.django_db
class TestNewBountiesEmail(TestCase):
"""Define tests for testing new bounties email."""

def setUp(self):
"""Perform setup for the testcase."""

Profile.objects.create(
data={},
handle='fred',
Expand Down Expand Up @@ -69,8 +69,7 @@ def setUp(self):
network='mainnet',
)


def test_get_bounties_for_keywords(self):
"""Test get_bounties_for_keywords function to confirm a bounty reserved for a specific user is excluded."""
new_bounties, _all_bounties = get_bounties_for_keywords('Python',24)
new_bounties, _all_bounties = get_bounties_for_keywords('Python', 24)
assert new_bounties.count() == 1

0 comments on commit b69604f

Please sign in to comment.