Skip to content

Commit

Permalink
Merge pull request arachnys#365 from arachnys/test-duty-rota
Browse files Browse the repository at this point in the history
Add test for ical parsing
  • Loading branch information
dbuxton committed Jul 20, 2016
2 parents 5819473 + e69ad96 commit 2580e71
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cabot/cabotapp/tests/fixtures/gcal_response.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Cabottest
X-WR-TIMEZONE:Europe/Copenhagen
X-WR-CALDESC:
BEGIN:VEVENT
DTSTART:20160719T130000Z
DTEND:20160719T160000Z
DTSTAMP:20160719T102406Z
UID:kf6gd4uc1hue70m7gkb7fdtsrc@google.com
CREATED:20160719T091318Z
DESCRIPTION:
LAST-MODIFIED:20160719T091320Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:troels
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
16 changes: 16 additions & 0 deletions cabot/cabotapp/tests/tests_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
GraphiteStatusCheck, JenkinsStatusCheck,
HttpStatusCheck, ICMPStatusCheck, Service, Instance,
StatusCheckResult, UserProfile, minimize_targets)
from cabot.cabotapp.calendar import get_events
from cabot.cabotapp.views import StatusCheckReportForm
from django.contrib.auth.models import Permission
from django.contrib.auth.models import User
from django.core import mail
from django.core.urlresolvers import reverse
from django.test.client import Client
from django.test.utils import override_settings
from django.utils import timezone
from mock import Mock, patch
from rest_framework import status, HTTP_HEADER_ENCODING
Expand Down Expand Up @@ -161,6 +163,13 @@ def fake_http_404_response(*args, **kwargs):
return resp


def fake_gcal_response(*args, **kwargs):
resp = Mock()
resp.content = get_content('gcal_response.ics')
resp.status_code = 200
return resp


def throws_timeout(*args, **kwargs):
raise requests.RequestException(u'фиктивная ошибка innit')

Expand Down Expand Up @@ -416,6 +425,13 @@ def test_duplicate_instance(self):
self.assertNotEqual(new.status_checks.all()[0], old.status_checks.all()[0])


class TestDutyRota(LocalTestCase):

@patch('cabot.cabotapp.models.requests.get', fake_gcal_response)
def test_duty_rota(self):
events = get_events()
self.assertEqual(events[0]['summary'], 'troels')

class TestWebInterface(LocalTestCase):

def setUp(self):
Expand Down
2 changes: 2 additions & 0 deletions cabot/celeryconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from datetime import timedelta

BROKER_URL = os.environ['CELERY_BROKER_URL']
# Set environment variable if you want to run tests without a redis instance
CELERY_ALWAYS_EAGER = os.environ.get('CELERY_ALWAYS_EAGER', False)
CELERY_IMPORTS = ('cabot.cabotapp.tasks', )
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
CELERY_TASK_SERIALIZER = "json"
Expand Down

0 comments on commit 2580e71

Please sign in to comment.