@ -1,19 +1,12 @@ | |||
from django.contrib.auth.hashers import make_password | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.accounts.models import Profile | |||
from hc.test import BaseTestCase | |||
class CheckTokenTestCase(TestCase): | |||
class CheckTokenTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(CheckTokenTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.profile = Profile(user=self.alice) | |||
self.profile.token = make_password("secret-token") | |||
self.profile.save() | |||
@ -0,0 +1,27 @@ | |||
from datetime import timedelta | |||
from django.test import TestCase | |||
from django.utils import timezone | |||
from hc.api.management.commands.ensuretriggers import Command | |||
from hc.api.models import Check | |||
class EnsureTriggersTestCase(TestCase): | |||
def test_ensure_triggers(self): | |||
Command().handle() | |||
check = Check.objects.create() | |||
assert check.alert_after is None | |||
check.last_ping = timezone.now() | |||
check.save() | |||
check.refresh_from_db() | |||
assert check.alert_after is not None | |||
alert_after = check.alert_after | |||
check.last_ping += timedelta(days=1) | |||
check.save() | |||
check.refresh_from_db() | |||
assert check.alert_after > alert_after |
@ -1,19 +1,11 @@ | |||
from django.conf import settings | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Channel | |||
from django.test.utils import override_settings | |||
class AddChannelTestCase(TestCase): | |||
from hc.api.models import Channel | |||
from hc.test import BaseTestCase | |||
def setUp(self): | |||
super(AddChannelTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
settings.PUSHOVER_API_TOKEN = "bogus_token" | |||
settings.PUSHOVER_SUBSCRIPTION_URL = "bogus_url" | |||
@override_settings(PUSHOVER_API_TOKEN="token", PUSHOVER_SUBSCRIPTION_URL="url") | |||
class AddChannelTestCase(BaseTestCase): | |||
def test_it_works(self): | |||
url = "/integrations/add/" | |||
@ -1,15 +1,8 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Check | |||
from hc.test import BaseTestCase | |||
class AddCheckTestCase(TestCase): | |||
def setUp(self): | |||
super(AddCheckTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
class AddCheckTestCase(BaseTestCase): | |||
def test_it_works(self): | |||
url = "/checks/add/" | |||
@ -1,16 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Channel | |||
from hc.test import BaseTestCase | |||
class ChannelChecksTestCase(TestCase): | |||
class ChannelChecksTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(ChannelChecksTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.channel = Channel(user=self.alice, kind="email") | |||
self.channel.value = "[email protected]" | |||
self.channel.save() | |||
@ -1,16 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Check, Ping | |||
from hc.test import BaseTestCase | |||
class LogTestCase(TestCase): | |||
class LogTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(LogTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.check = Check(user=self.alice) | |||
self.check.save() | |||
@ -1,16 +1,11 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Check | |||
from hc.test import BaseTestCase | |||
class MyChecksTestCase(TestCase): | |||
class MyChecksTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(MyChecksTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.check = Check(user=self.alice, name="Alice Was Here") | |||
self.check.save() | |||
@ -1,16 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Channel | |||
from hc.test import BaseTestCase | |||
class RemoveChannelTestCase(TestCase): | |||
class RemoveChannelTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(RemoveChannelTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.channel = Channel(user=self.alice, kind="email") | |||
self.channel.value = "[email protected]" | |||
self.channel.save() | |||
@ -1,16 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Check | |||
from hc.test import BaseTestCase | |||
class RemoveCheckTestCase(TestCase): | |||
class RemoveCheckTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(RemoveCheckTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.check = Check(user=self.alice) | |||
self.check.save() | |||
@ -1,16 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Channel, Check | |||
from hc.test import BaseTestCase | |||
class UpdateChannelTestCase(TestCase): | |||
class UpdateChannelTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(UpdateChannelTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.check = Check(user=self.alice) | |||
self.check.save() | |||
@ -1,16 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Check | |||
from hc.test import BaseTestCase | |||
class UpdateNameTestCase(TestCase): | |||
class UpdateNameTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(UpdateNameTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.check = Check(user=self.alice) | |||
self.check.save() | |||
@ -1,16 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Check | |||
from hc.test import BaseTestCase | |||
class UpdateTimeoutTestCase(TestCase): | |||
class UpdateTimeoutTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(UpdateTimeoutTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.check = Check(user=self.alice) | |||
self.check.save() | |||
@ -1,16 +1,11 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.api.models import Channel | |||
from hc.test import BaseTestCase | |||
class VerifyEmailTestCase(TestCase): | |||
class VerifyEmailTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(VerifyEmailTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.channel = Channel(user=self.alice, kind="email") | |||
self.channel.value = "[email protected]" | |||
self.channel.save() | |||
@ -1,17 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.payments.models import Subscription | |||
from mock import Mock, patch | |||
from hc.payments.models import Subscription | |||
from hc.test import BaseTestCase | |||
class BillingTestCase(TestCase): | |||
class BillingTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(BillingTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.sub = Subscription(user=self.alice) | |||
self.sub.subscription_id = "test-id" | |||
self.sub.customer_id = "test-customer-id" | |||
@ -1,17 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.payments.models import Subscription | |||
from mock import patch | |||
from hc.payments.models import Subscription | |||
from hc.test import BaseTestCase | |||
class CancelPlanTestCase(TestCase): | |||
class CancelPlanTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(CancelPlanTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.sub = Subscription(user=self.alice) | |||
self.sub.subscription_id = "test-id" | |||
self.sub.plan_id = "P5" | |||
@ -1,17 +1,11 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.accounts.models import Profile | |||
from hc.payments.models import Subscription | |||
from mock import patch | |||
from hc.accounts.models import Profile | |||
from hc.payments.models import Subscription | |||
from hc.test import BaseTestCase | |||
class CreatePlanTestCase(TestCase): | |||
def setUp(self): | |||
super(CreatePlanTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
class CreatePlanTestCase(BaseTestCase): | |||
def _setup_mock(self, mock): | |||
""" Set up Braintree calls that the controller will use. """ | |||
@ -1,16 +1,10 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.payments.models import Subscription | |||
from mock import patch | |||
from hc.payments.models import Subscription | |||
from hc.test import BaseTestCase | |||
class GetClientTokenTestCase(TestCase): | |||
def setUp(self): | |||
super(GetClientTokenTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
class GetClientTokenTestCase(BaseTestCase): | |||
@patch("hc.payments.views.braintree") | |||
def test_it_works(self, mock_braintree): | |||
@ -1,17 +1,13 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.payments.models import Subscription | |||
from mock import Mock, patch | |||
from hc.payments.models import Subscription | |||
from hc.test import BaseTestCase | |||
class InvoiceTestCase(TestCase): | |||
class InvoiceTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(InvoiceTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
self.sub = Subscription(user=self.alice) | |||
self.sub.subscription_id = "test-id" | |||
self.sub.customer_id = "test-customer-id" | |||
@ -1,15 +1,8 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
from hc.payments.models import Subscription | |||
from hc.test import BaseTestCase | |||
class PricingTestCase(TestCase): | |||
def setUp(self): | |||
super(PricingTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() | |||
class PricingTestCase(BaseTestCase): | |||
def test_anonymous(self): | |||
r = self.client.get("/pricing/") | |||
@ -0,0 +1,11 @@ | |||
from django.contrib.auth.models import User | |||
from django.test import TestCase | |||
class BaseTestCase(TestCase): | |||
def setUp(self): | |||
super(BaseTestCase, self).setUp() | |||
self.alice = User(username="alice", email="[email protected]") | |||
self.alice.set_password("password") | |||
self.alice.save() |