forked from data-exp-lab/girder_ythub
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from whole-tale/publish-refactor
Add publishInfo as array
- Loading branch information
Showing
8 changed files
with
225 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from bson import ObjectId | ||
import mock | ||
from tests import base | ||
|
||
|
||
def setUpModule(): | ||
base.enabledPlugins.append('wholetale') | ||
base.startServer() | ||
|
||
global JobStatus, Tale | ||
from girder.plugins.jobs.constants import JobStatus | ||
from girder.plugins.wholetale.models.tale import Tale | ||
|
||
|
||
def tearDownModule(): | ||
base.stopServer() | ||
|
||
|
||
class FakeJob: | ||
|
||
job = {} | ||
|
||
def delay(self, *args, **kwargs): | ||
return self.job | ||
|
||
|
||
class PublishTestCase(base.TestCase): | ||
def setUp(self): | ||
super(PublishTestCase, self).setUp() | ||
users = ( | ||
{ | ||
'email': 'root@dev.null', | ||
'login': 'admin', | ||
'firstName': 'Root', | ||
'lastName': 'van Klompf', | ||
'password': 'secret', | ||
}, | ||
{ | ||
'email': 'joe@dev.null', | ||
'login': 'joeregular', | ||
'firstName': 'Joe', | ||
'lastName': 'Regular', | ||
'password': 'secret', | ||
}, | ||
) | ||
self.admin, self.user = [ | ||
self.model('user').createUser(**user) for user in users | ||
] | ||
|
||
self.tale = self.model('tale', 'wholetale').createTale( | ||
{'_id': ObjectId()}, | ||
data=[], | ||
authors=self.user['firstName'] + ' ' + self.user['lastName'], | ||
creator=self.user, | ||
public=True, | ||
description="blah", | ||
title="Test", | ||
illustration='linkToImage', | ||
) | ||
|
||
def testPublish(self): | ||
with mock.patch('gwvolman.tasks.publish.apply_async'), mock.patch( | ||
'gwvolman.tasks.publish.delay' | ||
) as dl: | ||
|
||
dl.return_value = FakeJob() | ||
remoteMemberNode = 'remoteMemberURL' | ||
authToken = 'tokenXXX' | ||
|
||
resp = self.request( | ||
path='/publish/dataone', | ||
method='GET', | ||
user=self.user, | ||
params={ | ||
'taleId': str(self.tale['_id']), | ||
'remoteMemberNode': remoteMemberNode, | ||
'authToken': authToken, | ||
}, | ||
) | ||
self.assertStatusOk(resp) | ||
job_call = dl.call_args_list[-1][-1] | ||
job_call.pop('girder_client_token') | ||
self.assertDictEqual( | ||
job_call, | ||
( | ||
{ | ||
'dataone_auth_token': authToken, | ||
'dataone_node': remoteMemberNode, | ||
'tale': str(self.tale['_id']), | ||
'user_id': str(self.user['_id']), | ||
} | ||
), | ||
) | ||
|
||
def tearDown(self): | ||
self.model('user').remove(self.user) | ||
self.model('user').remove(self.admin) | ||
super(PublishTestCase, self).tearDown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.