Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
timmow committed Jul 7, 2014
1 parent 04af8b0 commit 6b21d03
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions features/admin/csv_upload.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@use_admin_client
Feature: CSV Upload

@bob
Scenario: Upload CSV data
Given I have a data_set named "my_data_set" with settings
| key | value |
Expand Down
9 changes: 8 additions & 1 deletion features/support/api_common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .stagecraft import create_or_update_stagecraft_service
from .stagecraft import (create_or_update_stagecraft_service,
create_or_update_backdrop_service)


TEST_STAGECRAFT_PORT = 3204
Expand Down Expand Up @@ -32,5 +33,11 @@ def ensure_data_set_exists(context, data_set_name, settings={}):
}

create_or_update_stagecraft_service(context, TEST_STAGECRAFT_PORT, routes)
backdrop_routes = {
('POST', u'/data/{}/{}'.format(
response['data_group'], response['data_type'])): [response],
}
create_or_update_backdrop_service(context, 3039,
backdrop_routes)

context.data_set = data_set_name
17 changes: 13 additions & 4 deletions features/support/stagecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,33 @@

def create_or_update_stagecraft_service(context, port, routes):
if 'mock_stagecraft_service' not in context or not context.mock_stagecraft_service:
context.mock_stagecraft_service = StagecraftService(port, routes)
context.mock_stagecraft_service = FakeService(port, routes, 'stagecraft')
context.mock_stagecraft_service.start()
else:
context.mock_stagecraft_service.add_routes(routes)
return context.mock_stagecraft_service


def create_or_update_backdrop_service(context, port, routes):
if 'mock_backdrop_service' not in context or not context.mock_backdrop_service:
context.mock_backdrop_service = FakeService(port, routes, 'backdrop')
context.mock_backdrop_service.start()
else:
context.mock_backdrop_service.add_routes(routes)
return context.mock_backdrop_service


def stop_stagecraft_service_if_running(context):
if 'mock_stagecraft_service' in context and context.mock_stagecraft_service:
context.mock_stagecraft_service.stop()
context.mock_stagecraft_service = None


class StagecraftService(object):
def __init__(self, port, routes):
class FakeService(object):
def __init__(self, port, routes, app_name):
self.__port = port
self.__routes = routes
self.__app = Flask('fake_stagecraft')
self.__app = Flask('fake_{}'.format(app_name))
self.__proc = None

@self.__app.route('/', defaults={'path': ''})
Expand Down
8 changes: 5 additions & 3 deletions features/support/tests/test_stagecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from nose.tools import assert_raises
from hamcrest import assert_that, is_

from ..stagecraft import StagecraftService, \
from ..stagecraft import FakeService, \
create_or_update_stagecraft_service, stop_stagecraft_service_if_running


Expand Down Expand Up @@ -65,9 +65,11 @@ def test_stop_stagecraft_if_running():

class TestStagecraftService(object):
def create_service(self):
return StagecraftService(8089, {
return FakeService(8089, {
('GET', u'example'): {u'foo': u'bar'}
})
},
'stagecraft'
)

def test_service_catches_calls(self):
service = self.create_service()
Expand Down

0 comments on commit 6b21d03

Please sign in to comment.