From 8ec2e5cd29f25e11da380056f17aa359569f2421 Mon Sep 17 00:00:00 2001 From: Oliver Marks Date: Mon, 22 Jan 2018 22:36:02 +0000 Subject: [PATCH] Remove volume causing permission issues --- compose/django/stage-gunicorn-mhackspace.sh | 1 - live.yml | 1 - mhackspace/subscriptions/tests/mocks.py | 31 ++++++++++++++++++- .../tests/test_payment_gateways.py | 15 ++++++++- stage.yml | 1 - 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/compose/django/stage-gunicorn-mhackspace.sh b/compose/django/stage-gunicorn-mhackspace.sh index 178d42e..ea408d1 100644 --- a/compose/django/stage-gunicorn-mhackspace.sh +++ b/compose/django/stage-gunicorn-mhackspace.sh @@ -1,6 +1,5 @@ #!/bin/sh python /app/manage.py collectstatic --noinput python /app/manage.py compilescss -chmod -R 664 /var/log/gunicorn /usr/local/bin/gunicorn config.wsgi -w 2 -b unix:/data/sockets/stage-gunicorn-mhackspace.sock --error-logfile /var/log/gunicorn/stage-gunicorn-mhackspace.log --chdir=/app diff --git a/live.yml b/live.yml index 89c901d..bd819da 100644 --- a/live.yml +++ b/live.yml @@ -28,7 +28,6 @@ services: env_file: .env volumes: - .:/app - - ./compose/data/logs:/var/log/gunicorn - sockets:/data/sockets node: diff --git a/mhackspace/subscriptions/tests/mocks.py b/mhackspace/subscriptions/tests/mocks.py index 58c5ccd..c382c9b 100644 --- a/mhackspace/subscriptions/tests/mocks.py +++ b/mhackspace/subscriptions/tests/mocks.py @@ -34,7 +34,8 @@ class gocardlessMocks(TestCase): return self.provider - def mock_success_responses(self): + def mock_success_responses(self, responses=None): + if responses == None: subscription_properties = Mock( id='02', status='active', @@ -62,3 +63,31 @@ class gocardlessMocks(TestCase): self.provider.client.subscriptions.cancel = PropertyMock( return_value={'status_code': '200'}) + + def mock_success_responses2(self, responses=None): + if responses == None: + responses = [Mock( + id='02', + status='active', + amount=20.00, + created_at='date' + )] + + mock_list = MagicMock() + mock_list_records = MagicMock(side_effect=[subscription_properties]) + mock_list.records.return_value = mock_list_records + + self.provider.client.subscriptions.list = mock_list + ApiResponse = namedtuple('ApiResponse', 'api_response, created_at') + ApiResponseStatus = namedtuple('ApiResponseStatus', 'status_code') + + self.provider.client.subscriptions.create = Mock( + return_value=ApiResponse( + created_at=self.date_now, + api_response=ApiResponseStatus(status_code='200')) + ) + + self.provider.client.subscriptions.get.side_effects = responses + self.provider.client.subscriptions.cancel = PropertyMock( + return_value={'status_code': '200'}) + diff --git a/mhackspace/subscriptions/tests/test_payment_gateways.py b/mhackspace/subscriptions/tests/test_payment_gateways.py index 2a35305..c35d102 100644 --- a/mhackspace/subscriptions/tests/test_payment_gateways.py +++ b/mhackspace/subscriptions/tests/test_payment_gateways.py @@ -16,7 +16,20 @@ class TestPaymentGatewaysGocardless(gocardlessMocks): super().setUp() def test_unsubscribe(self): - self.mock_success_responses() + responses = [ + Mock( + id='02', + status='active', + amount=20.00, + created_at='date' + ), Mock( + id='03', + status='active2', + amount=40.00, + created_at='date' + ), + ] + self.mock_success_responses2(responses) result = self.provider.cancel_subscription(user=self.user, reference='M01') diff --git a/stage.yml b/stage.yml index 8effba7..7760e90 100644 --- a/stage.yml +++ b/stage.yml @@ -28,7 +28,6 @@ services: env_file: .env volumes: - .:/app - - ./compose/data/logs:/var/log/gunicorn - sockets:/data/sockets node: