From 4057759df6af987b81c37479ac2feea99fadaab0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C4=93teris=20Caune?=
Date: Thu, 25 Jun 2015 22:29:19 +0300
Subject: [PATCH] Setting up tests
---
hc/.travis.yml | 8 ++++++++
hc/front/tests.py | 3 ---
hc/front/tests/__init__.py | 0
hc/front/tests/test_basics.py | 8 ++++++++
hc/settings.py | 15 +++++++++------
templates/docs.html | 2 +-
templates/index.html | 2 +-
7 files changed, 27 insertions(+), 11 deletions(-)
create mode 100644 hc/.travis.yml
delete mode 100644 hc/front/tests.py
create mode 100644 hc/front/tests/__init__.py
create mode 100644 hc/front/tests/test_basics.py
diff --git a/hc/.travis.yml b/hc/.travis.yml
new file mode 100644
index 00000000..21de06f8
--- /dev/null
+++ b/hc/.travis.yml
@@ -0,0 +1,8 @@
+language: python
+python:
+ - "3.4"
+install: "pip install -r requirements.txt"
+addons:
+ postgresql: "9.4"
+script:
+ - python manage.py test hc.front
\ No newline at end of file
diff --git a/hc/front/tests.py b/hc/front/tests.py
deleted file mode 100644
index 7ce503c2..00000000
--- a/hc/front/tests.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.test import TestCase
-
-# Create your tests here.
diff --git a/hc/front/tests/__init__.py b/hc/front/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/hc/front/tests/test_basics.py b/hc/front/tests/test_basics.py
new file mode 100644
index 00000000..e180c56d
--- /dev/null
+++ b/hc/front/tests/test_basics.py
@@ -0,0 +1,8 @@
+from django.test import TestCase
+
+
+class BasicsTestCase(TestCase):
+
+ def test_it_shows_welcome(self):
+ r = self.client.get("/")
+ self.assertContains(r, "Welcome", status_code=200)
diff --git a/hc/settings.py b/hc/settings.py
index 02595787..64acc1e2 100644
--- a/hc/settings.py
+++ b/hc/settings.py
@@ -15,7 +15,12 @@ import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-hc_config = json.loads(open(os.path.expanduser("~/hc_config.json")).read())
+p = os.path.expanduser("~/hc_config.json")
+if os.path.exists(p):
+ hc_config = json.loads(open(p).read())
+else:
+ print("~/hc_config.json does not exist, using defaults")
+ hc_config = {}
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
@@ -84,10 +89,8 @@ DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'hc',
- 'USER': 'hc',
+ 'USER': 'postgres',
'PASSWORD': '',
- 'HOST': '192.168.1.112',
- 'PORT': 5432,
'TEST': {'CHARSET': 'UTF8'}
}
}
@@ -113,7 +116,7 @@ STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
# AWS
EMAIL_BACKEND = 'django_ses_backend.SESBackend'
-AWS_SES_ACCESS_KEY_ID = hc_config["aws_ses_access_key"]
-AWS_SES_SECRET_ACCESS_KEY = hc_config["aws_ses_secret_key"]
+AWS_SES_ACCESS_KEY_ID = hc_config.get("aws_ses_access_key")
+AWS_SES_SECRET_ACCESS_KEY = hc_config.get("aws_ses_secret_key")
AWS_SES_REGION_NAME = 'eu-west-1'
AWS_SES_REGION_ENDPOINT = 'email.eu-west-1.amazonaws.com'
diff --git a/templates/docs.html b/templates/docs.html
index bbb43cfe..ee357453 100644
--- a/templates/docs.html
+++ b/templates/docs.html
@@ -33,7 +33,7 @@
In bash scripts, you can use wget
or curl
to run the requests:
-wget https://healthchecks.io/ping/b2012751-c542-4deb-b054-ff51322102b9/
+wget https://healthchecks.io/ping/b2012751-c542-4deb-b054-ff51322102b9/ -O /dev/null
When notifications are sent
diff --git a/templates/index.html b/templates/index.html
index 030f9dff..faefafc6 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -29,7 +29,7 @@
-
wget https://healthchecks.io/ping/b2012751-c542-4deb-b054-ff51322102b9/
+ wget https://healthchecks.io/ping/b2012751-c542-4deb-b054-ff51322102b9/ -O /dev/null