-
Notifications
You must be signed in to change notification settings - Fork 24
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 #1042 from parklab/jkmarx/add-file-download-data-set2
Jkmarx/add file download data set2
- Loading branch information
Showing
11 changed files
with
463 additions
and
91 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
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,25 @@ | ||
'use strict'; | ||
|
||
angular | ||
.module('refineryApp') | ||
.factory('assayAttributeService', ['$resource', 'settings', | ||
function ($resource, settings) { | ||
var assayAttribute = $resource( | ||
settings.appRoot + settings.refineryApiV2 + '/assays/:uuid/attributes/', | ||
{ | ||
uuid: '@uuid' | ||
}, | ||
{ | ||
query: { | ||
method: 'GET', | ||
isArray: true | ||
}, | ||
|
||
update: { | ||
method: 'PUT' | ||
} | ||
} | ||
); | ||
return assayAttribute; | ||
} | ||
]); |
141 changes: 141 additions & 0 deletions
141
refinery/ui/source/js/commons/services/assay-attribute.spec.js
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,141 @@ | ||
'use strict'; | ||
|
||
describe('Common.service.assayAttribute: unit tests', function () { | ||
var $httpBackend; | ||
var $rootScope; | ||
var fakeUuid = 'x508x83x-x9xx-4740-x9x7-x7x0x631280x'; | ||
var service; | ||
var settings; | ||
var fakeResponse = [ | ||
{ | ||
assay: 3, | ||
study: 6, | ||
solr_field: 'uuid', | ||
rank: 1, | ||
is_exposed: true, | ||
is_facet: false, | ||
is_active: false, | ||
is_internal: true, | ||
id: 43, | ||
display_name: 'uuid' | ||
}, | ||
{ | ||
assay: 3, | ||
study: 6, | ||
solr_field: 'REFINERY_ANALYSIS_UUID_6_3_s', | ||
rank: 2, | ||
is_exposed: true, | ||
is_facet: true, | ||
is_active: false, | ||
is_internal: false, | ||
id: 42, | ||
display_name: 'Analysis' | ||
}, | ||
{ | ||
assay: 3, | ||
study: 6, | ||
solr_field: 'REFINERY_NAME_6_3_s', | ||
rank: 3, | ||
is_exposed: false, | ||
is_facet: true, | ||
is_active: true, | ||
is_internal: false, | ||
id: 52, | ||
display_name: 'Name' | ||
} | ||
]; | ||
|
||
var putAttribute = { | ||
uuid: fakeUuid, | ||
solr_field: 'REFINERY_NAME_6_3_s', | ||
rank: 1, | ||
is_exposed: false, | ||
is_facet: false | ||
}; | ||
|
||
var putResponse = { | ||
assay: 3, | ||
study: 6, | ||
solr_field: 'REFINERY_NAME_6_3_s', | ||
rank: 3, | ||
is_exposed: false, | ||
is_facet: true, | ||
is_active: true, | ||
is_internal: false, | ||
id: 52, | ||
display_name: 'Name' | ||
}; | ||
|
||
beforeEach(function () { | ||
module('refineryApp'); | ||
|
||
inject(function ($injector) { | ||
settings = $injector.get('settings'); | ||
$httpBackend = $injector.get('$httpBackend'); | ||
$rootScope = $injector.get('$rootScope'); | ||
service = $injector.get('assayAttributeService'); | ||
}); | ||
}); | ||
|
||
describe('Service', function () { | ||
it('should be defined', function () { | ||
expect(service).toBeDefined(); | ||
}); | ||
|
||
it('should be a method', function () { | ||
expect(typeof service).toEqual('function'); | ||
}); | ||
|
||
it('query should return a resolving promise', function () { | ||
$httpBackend | ||
.expectGET( | ||
settings.appRoot + | ||
settings.refineryApiV2 + | ||
'/assays/' + fakeUuid + '/attributes/' | ||
).respond(200, fakeResponse); | ||
|
||
var results; | ||
var promise = service.query({ | ||
uuid: fakeUuid | ||
}).$promise.then(function (response) { | ||
results = response; | ||
}); | ||
|
||
expect(typeof promise.then).toEqual('function'); | ||
$httpBackend.flush(); | ||
$rootScope.$digest(); | ||
expect(results.length).toEqual(fakeResponse.length); | ||
for (var i = 0; i < results.length; i++) { | ||
expect(results[i].solr_field).toEqual(fakeResponse[i].solr_field); | ||
} | ||
}); | ||
|
||
it('update should return a resolving promise', function () { | ||
$httpBackend | ||
.expectPUT( | ||
settings.appRoot + | ||
settings.refineryApiV2 + | ||
'/assays/' + fakeUuid + '/attributes/', | ||
putAttribute | ||
).respond(200, putResponse); | ||
|
||
var results; | ||
var promise = service.update(putAttribute).$promise.then(function (response) { | ||
results = response; | ||
}); | ||
|
||
expect(typeof promise.then).toEqual('function'); | ||
$httpBackend.flush(); | ||
$rootScope.$digest(); | ||
expect(results).toBeDefined(); | ||
expect(results.solr_field).toEqual(putResponse.solr_field); | ||
expect(results.rank).toEqual(putResponse.rank); | ||
|
||
results = undefined; | ||
promise = service.update().$promise.then(function (response) { | ||
results = response; | ||
}); | ||
expect(results).not.toBeDefined(); | ||
}); | ||
}); | ||
}); |
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,25 @@ | ||
'use strict'; | ||
|
||
angular | ||
.module('refineryApp') | ||
.factory('nodeService', ['$resource', 'settings', | ||
function ($resource, settings) { | ||
var node = $resource( | ||
settings.appRoot + settings.refineryApi + '/node/:uuid/', | ||
{ | ||
uuid: 'uuid', | ||
format: 'json', | ||
}, | ||
{ | ||
query: { | ||
method: 'GET', | ||
isArray: false | ||
} | ||
} | ||
); | ||
|
||
return node; | ||
} | ||
]); | ||
|
||
// http://192.168.50.50:8000/api/v1/node/0c2778e8-eed5-4981-9ccb-5f1ff75571d5/?format=json |
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,70 @@ | ||
'use strict'; | ||
|
||
describe('Common.service.node: unit tests', function () { | ||
var $httpBackend; | ||
var $rootScope; | ||
var fakeUuid = 'x508x83x-x9xx-4740-x9x7-x7x0x631280x'; | ||
var service; | ||
var fakeResponse = { | ||
analysis_uuid: null, | ||
assay: '/api/v1/assay/5eff885e-49cb-477a-ad76-f65d74d78f8a/', | ||
attributes: [], | ||
file_import_status: 'PENDING', | ||
file_url: '/media/file_store/c5/d2/rfc174.txt', | ||
file_uuid: 'd25467be-3185-45d8-bd62-385dd54dde5a', | ||
name: 'http://gehlenborg.com/wp-content/uploads/rfc/rfc174.txt', | ||
parents: [ | ||
'/api/v1/node/2d59008b-5abe-4f35-9199-81b75f7e9eef/' | ||
], | ||
resource_uri: '/api/v1/node/63647300-3117-4c7b-9205-706ac4daa7fa/', | ||
study: '/api/v1/study/ff657398-30db-4481-bfb9-8b86f46e9000/', | ||
subanalysis: null, | ||
type: 'Raw Data File', | ||
uuid: '63647300-3117-4c7b-9205-706ac4daa7fa' | ||
}; | ||
|
||
beforeEach(function () { | ||
module('refineryApp'); | ||
|
||
inject(function ($injector) { | ||
var settings = $injector.get('settings'); | ||
$httpBackend = $injector.get('$httpBackend'); | ||
$rootScope = $injector.get('$rootScope'); | ||
service = $injector.get('nodeService'); | ||
|
||
$httpBackend | ||
.expectGET( | ||
settings.appRoot + | ||
settings.refineryApi + | ||
'/node/' + fakeUuid + '/?format=json' | ||
).respond(200, fakeResponse); | ||
}); | ||
}); | ||
|
||
describe('Service', function () { | ||
it('should be defined', function () { | ||
expect(service).toBeDefined(); | ||
}); | ||
|
||
it('should be a method', function () { | ||
expect(typeof service).toEqual('function'); | ||
}); | ||
|
||
it('should return a resolving promise', function () { | ||
var results; | ||
var promise = service.query({ | ||
uuid: fakeUuid | ||
}).$promise.then(function (response) { | ||
results = response; | ||
}); | ||
|
||
expect(typeof promise.then).toEqual('function'); | ||
$httpBackend.flush(); | ||
$rootScope.$digest(); | ||
expect(results.file_url) | ||
.toEqual(fakeResponse.file_url); | ||
expect(results.uuid).toEqual(fakeResponse.uuid); | ||
expect(results.file_uuid).toEqual(fakeResponse.file_uuid); | ||
}); | ||
}); | ||
}); |
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.