mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-07 13:34:53 +03:00
Added tests for entry point
This commit is contained in:
parent
209afd5c47
commit
43d8b661b8
|
@ -14,7 +14,7 @@ import psycopg2
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
def exports(list=None):
|
def exports(**kwargs):
|
||||||
"""Useful environment variables
|
"""Useful environment variables
|
||||||
:list: TODO
|
:list: TODO
|
||||||
"""
|
"""
|
||||||
|
@ -25,7 +25,6 @@ def pingpost():
|
||||||
"""
|
"""
|
||||||
This is the function that actually trys to connect
|
This is the function that actually trys to connect
|
||||||
to postgres
|
to postgres
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if os.environ['POSTGRES_USER']:
|
if os.environ['POSTGRES_USER']:
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
from unittest.mock import patch, PropertyMock
|
||||||
|
import unittest
|
||||||
|
import entrypoint
|
||||||
|
|
||||||
|
class TestEntrypoint(unittest.TestCase):
|
||||||
|
|
||||||
|
"""
|
||||||
|
We test that the entry point script works.
|
||||||
|
"""
|
||||||
|
def setUp(self):
|
||||||
|
self.prop = 'test'
|
||||||
|
|
||||||
|
def test_exports(self):
|
||||||
|
with patch.dict(entrypoint.os.environ, {'newkey': 'newvalue'}, clear=True):
|
||||||
|
entrypoint.exports()
|
||||||
|
self.assertTrue(entrypoint.os.environ['REDIS_URL'])
|
||||||
|
self.assertTrue(entrypoint.os.environ['CELERY_BROKER_URL'])
|
||||||
|
self.assertTrue(entrypoint.os.environ['newkey'])
|
||||||
|
|
||||||
|
@patch('entrypoint.psycopg2.connect')
|
||||||
|
def test_pingpost(self, mockConn):
|
||||||
|
"""
|
||||||
|
We must assert that psycopg2 conn is called
|
||||||
|
"""
|
||||||
|
with patch.dict(entrypoint.os.environ, {
|
||||||
|
'POSTGRES_USER': 'newvalue',
|
||||||
|
'POSTGRES_PASSWORD': 'test'}, clear=True):
|
||||||
|
entrypoint.main(('dir',))
|
||||||
|
self.assertTrue(mockConn.called)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user