mirror of
https://github.com/status-im/cabot.git
synced 2025-02-24 10:28:06 +00:00
Fix tests
This commit is contained in:
parent
82546b1620
commit
f5de2c64bc
@ -1,22 +1,25 @@
|
||||
import requests
|
||||
from cabotapp.alert import _send_hipchat_alert
|
||||
from django.utils import timezone
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User
|
||||
from cabotapp.models import (StatusCheck, GraphiteStatusCheck, JenkinsStatusCheck,
|
||||
HttpStatusCheck, Service, StatusCheckResult)
|
||||
from mock import Mock, patch
|
||||
from twilio import rest
|
||||
from django.core import mail
|
||||
from datetime import timedelta
|
||||
from mock import Mock, patch
|
||||
import json
|
||||
import os
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.core import mail
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
from twilio import rest
|
||||
import requests
|
||||
|
||||
from app.cabotapp.alert import _send_hipchat_alert
|
||||
from app.cabotapp.models import (StatusCheck, GraphiteStatusCheck, JenkinsStatusCheck,
|
||||
HttpStatusCheck, Service, StatusCheckResult)
|
||||
|
||||
def get_content(fname):
|
||||
path = os.path.join(os.path.dirname(__file__), 'fixtures/%s' % fname)
|
||||
with open(path) as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
class LocalTestCase(TestCase):
|
||||
def setUp(self):
|
||||
requests.get = Mock()
|
||||
@ -49,6 +52,7 @@ def fake_http_404_response(*args, **kwargs):
|
||||
resp.status_code = 404
|
||||
return resp
|
||||
|
||||
|
||||
class TestCheckRun(LocalTestCase):
|
||||
def setUp(self):
|
||||
super(TestCheckRun, self).setUp()
|
||||
@ -128,7 +132,7 @@ class TestCheckRun(LocalTestCase):
|
||||
self.service.update_status()
|
||||
self.assertEqual(self.service.overall_status, Service.PASSING_STATUS)
|
||||
|
||||
@patch('cabotapp.graphite.requests.get', fake_graphite_response)
|
||||
@patch('app.cabotapp.graphite.requests.get', fake_graphite_response)
|
||||
def test_graphite_run(self):
|
||||
checkresults = self.graphite_check.statuscheckresult_set.all()
|
||||
self.assertEqual(len(checkresults), 2)
|
||||
@ -148,7 +152,7 @@ class TestCheckRun(LocalTestCase):
|
||||
self.assertEqual(len(checkresults), 4)
|
||||
self.assertEqual(self.graphite_check.calculated_status, Service.CALCULATED_PASSING_STATUS)
|
||||
|
||||
@patch('cabotapp.jenkins.requests.get', fake_jenkins_response)
|
||||
@patch('app.cabotapp.jenkins.requests.get', fake_jenkins_response)
|
||||
def test_jenkins_run(self):
|
||||
checkresults = self.jenkins_check.statuscheckresult_set.all()
|
||||
self.assertEqual(len(checkresults), 0)
|
||||
@ -157,7 +161,7 @@ class TestCheckRun(LocalTestCase):
|
||||
self.assertEqual(len(checkresults), 1)
|
||||
self.assertFalse(self.jenkins_check.last_result().succeeded)
|
||||
|
||||
@patch('cabotapp.models.requests.get', fake_http_200_response)
|
||||
@patch('app.cabotapp.models.requests.get', fake_http_200_response)
|
||||
def test_http_run(self):
|
||||
checkresults = self.http_check.statuscheckresult_set.all()
|
||||
self.assertEqual(len(checkresults), 0)
|
||||
@ -172,7 +176,7 @@ class TestCheckRun(LocalTestCase):
|
||||
self.assertFalse(self.http_check.last_result().succeeded)
|
||||
self.assertEqual(self.http_check.calculated_status, Service.CALCULATED_FAILING_STATUS)
|
||||
|
||||
@patch('cabotapp.models.requests.get', fake_http_404_response)
|
||||
@patch('app.cabotapp.models.requests.get', fake_http_404_response)
|
||||
def test_http_run_bad_resp(self):
|
||||
checkresults = self.http_check.statuscheckresult_set.all()
|
||||
self.assertEqual(len(checkresults), 0)
|
||||
@ -181,8 +185,3 @@ class TestCheckRun(LocalTestCase):
|
||||
self.assertEqual(len(checkresults), 1)
|
||||
self.assertFalse(self.http_check.last_result().succeeded)
|
||||
self.assertEqual(self.http_check.calculated_status, Service.CALCULATED_FAILING_STATUS)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
16
app/urls.py
16
app/urls.py
@ -1,18 +1,20 @@
|
||||
from django.conf.urls.defaults import patterns, include, url
|
||||
from cabotapp.views import (run_status_check, update_service,
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.views import login, logout, password_reset, password_reset_done, password_reset_confirm
|
||||
from django.views.generic.base import RedirectView
|
||||
admin.autodiscover()
|
||||
|
||||
from app.cabotapp.views import (run_status_check, update_service,
|
||||
graphite_api_data, twiml_callback, checks_run_recently,
|
||||
GraphiteCheckCreateView, GraphiteCheckUpdateView,
|
||||
HttpCheckCreateView, HttpCheckUpdateView,
|
||||
JenkinsCheckCreateView, JenkinsCheckUpdateView,
|
||||
StatusCheckDeleteView, StatusCheckListView, StatusCheckDetailView,
|
||||
StatusCheckResultDetailView)
|
||||
from cabotapp.views import (ServiceListView, ServiceDetailView,
|
||||
StatusCheckResultDetailView,
|
||||
ServiceListView, ServiceDetailView,
|
||||
ServiceUpdateView, ServiceCreateView, ServiceDeleteView,
|
||||
UserProfileUpdateView, ShiftListView, subscriptions)
|
||||
from django.contrib import admin
|
||||
from django.views.generic.base import RedirectView
|
||||
from django.contrib.auth.views import login, logout, password_reset, password_reset_done, password_reset_confirm
|
||||
admin.autodiscover()
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', view=RedirectView.as_view(url='services/', permanent=False), name='dashboard'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user