Skip to content

Commit

Permalink
Merge branch 'release/3.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorOctober committed Oct 21, 2015
2 parents 08aec8b + 906c64c commit 5279a66
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0
3.1.1
2 changes: 1 addition & 1 deletion springboard/tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_ga_pageviews(self, mock_task):
'HTTP_HOST': 'some.site.com',
'REMOTE_ADDR': '192.0.0.1',
})
mock_task.assert_called_once()
self.assertEqual(mock_task.call_count, 1)
((profile_id, gen_client_id, data), _) = mock_task.call_args_list[0]
self.assertEqual(profile_id, 'UA-some-id')
self.assertEqual(data['path'], '/')
Expand Down
22 changes: 13 additions & 9 deletions springboard/tests/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pyramid import testing

from mock import patch
from mock import patch, MagicMock

from springboard.tests.base import SpringboardTestCase
from springboard.tasks import pull
Expand All @@ -23,21 +23,25 @@ def tearDown(self):

@patch('springboard.tasks.RemoteStorageManager')
@patch('springboard.tasks.EG.workspace')
def test_pull(self, mocked_workspace, mocked_rsm):
def test_pull(self, mocked_workspace_init, mocked_rsm_init):
local_repo_url = repo_url('repos', 'foo')
remote_repo_url = repo_url('repos', 'http://localhost/repos/foo.json')
es = {'urls': ['http://host:port']}
mocked_workspace = MagicMock()
mocked_workspace_init.return_value = mocked_workspace
mocked_rsm = MagicMock()
mocked_rsm_init.return_value = mocked_rsm

pull.delay(local_repo_url, index_prefix='foo', es=es)
mocked_workspace.assert_called_once_with(
mocked_workspace_init.assert_called_once_with(
local_repo_url,
index_prefix='foo',
es=es)
mocked_workspace.pull.assert_called_once()
mocked_rsm.assert_not_called()
self.assertEqual(mocked_workspace.pull.call_count, 1)
self.assertFalse(mocked_rsm_init.called)

mocked_workspace.reset_mock()
mocked_workspace_init.reset_mock()
pull.delay(remote_repo_url, index_prefix='foo', es=es)
mocked_rsm.assert_called_once_with(remote_repo_url)
mocked_rsm.pull.assert_called_once()
mocked_workspace.assert_not_called()
mocked_rsm_init.assert_called_once_with(remote_repo_url)
self.assertEqual(mocked_rsm.pull.call_count, 1)
self.assertFalse(mocked_workspace_init.called)
4 changes: 2 additions & 2 deletions springboard/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def test_cachingrepohelper(self, mocked_branch_name):
mocked_branch_name.return_value = 'branch-foo'
repo = CachingRepoHelper('http://domain/repo/foo')
self.assertEqual(repo.active_branch_name(), 'branch-foo')
mocked_branch_name.assert_called_once()
self.assertEqual(mocked_branch_name.call_count, 1)
# check that 2nd call is cached
self.assertEqual(repo.active_branch_name(), 'branch-foo')
mocked_branch_name.assert_called_once()
self.assertEqual(mocked_branch_name.call_count, 1)


class TestPaginator(TestCase):
Expand Down
11 changes: 10 additions & 1 deletion springboard/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ def test_page(self):
self.assertEqual(context['all_categories'].count(), 1)
self.assertEqual(context['all_pages'].count(), 1)

def test_page_with_no_category(self):
[page] = self.mk_pages(self.workspace, count=1)
views = CoreViews(
self.mk_request(matchdict={'uuid': page.uuid}))
context = views.page()
self.assertEqual(context['page'].uuid, page.uuid)
self.assertEqual(context['all_categories'].count(), 0)
self.assertEqual(context['all_pages'].count(), 1)

def test_flatpage(self):
[page] = self.mk_pages(self.workspace, count=1)
views = CoreViews(
Expand All @@ -82,7 +91,7 @@ def test_api_notify(self, mock_delay):

views = CoreViews(request)
response = views.api_notify()
mock_delay.assert_called_once()
self.assertEqual(mock_delay.call_count, 1)
args, kwargs = mock_delay.call_args
self.assertEqual(response, {})
self.assertEqual(kwargs['repo_url'], self.workspace.working_dir)
Expand Down
6 changes: 4 additions & 2 deletions springboard/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ def search(self):
def page(self):
uuid = self.request.matchdict['uuid']
[page] = self.all_pages.filter(uuid=uuid)
[category] = self.all_categories.filter(
uuid=page.primary_category)
category = None
if page.primary_category:
[category] = self.all_categories.filter(
uuid=page.primary_category)
return self.context(category=category,
page=page)

Expand Down

0 comments on commit 5279a66

Please sign in to comment.