def test_cost_case_insensitive(self): """Sending correct value but with wrong case as 'cost' Purpose: What happens when we send correct value but with incorrect case (free instead of Free) Sent: Value with correct string but lowercase (free instead of Free) Expected outcome: Resource registered with correct case """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_cost_case_insensitive' sent_resource['cost'] = 'free' response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_cost_case_insensitive', format='json') expected_resource = emptyOutputTool() expected_resource['id'] = 'test_cost_case_insensitive' expected_resource['cost'] = 'Free' received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(expected_resource, received_resource)
def test_inp_dataType_extra_fields(self): """Sending array of dicts with extra fields as 'dataType' Purpose: What happens when we send wrong type as the field (this case - add some fields to the object) Sent: Array of arrays of mixed types Expected outcome: Resource is registered, extra fields are ignored. """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_inp_dataType_extra_fields' sent_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' }], 'input': [{ 'dataType': { 'uri': 'http://edamontology.org/data_2044', 'some': 'field' } }] }] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_inp_dataType_extra_fields', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_inp_dataType_extra_fields' expected_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' }], 'functionDescription': None, 'functionHandle': None, 'input': [{ 'dataType': { 'uri': 'http://edamontology.org/data_2044', 'term': 'Sequence' }, 'dataFormat': [], 'dataHandle': None, 'dataDescription': None }], 'output': [] }] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_contactEmail_correct(self): """Sending a correctly formatted string as 'contactEmail' Purpose: Basic test of successful sending of a string as contactEmail Sent: contactEmail as a string Expected outcome: Resource registered with the sent string """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_contactEmail_correct' sent_resource['contact'] = [{'contactEmail': '*****@*****.**'}] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_contactEmail_correct', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_contactEmail_correct' expected_resource['contact'] = [{ 'contactEmail': '*****@*****.**', 'contactURL': None, 'contactName': None, 'contactTel': None }] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_homepage_non_ascii(self): """Sending string with non-ascii characters as 'homepage' Purpose: What happens when we send non-ascii characters Sent: String with non-ascii characters Expected outcome: Resource registered with non-ascii URL """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_homepage_non_ascii' sent_resource['homepage'] = u'http://ąęćżźń£ØΔ♥†.com' response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_homepage_non_ascii', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_homepage_non_ascii' expected_resource['homepage'] = u'http://ąęćżźń£ØΔ♥†.com' received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_collection_duplicate(self): """Sending two identical strings as 'collection' Purpose: Checking if the system will remove duplicate elements Sent: Two identical collection strings Expected outcome: Resource registered without the duplicate string """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_collection_duplicate' sent_resource['collection'] = [ 'Just a collection', 'Just a collection' ] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_collection_duplicate', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_collection_duplicate' expected_resource['collection'] = ['Just a collection'] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertItemsEqual(expected_resource, received_resource)
def test_resource_creation_correct(self): """Sending one of allowed values as 'accessibility' Purpose: Basic test of successful sending of an allowed value for accessibility Sent: Allowed value for accessibility Expected outcome: Resource registered with the sent value """ sent_resource = emptyInputTool() sent_resource['accessibility'] = ['Open access'] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/Resource_Name', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['biotoolsID'] = 'Resource_Name' expected_resource['accessibility'] = ['Open access'] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertItemsEqual(expected_resource, received_resource)
def test_publicationsPrimaryID_correct_1(self): """Sending one of the allowed values as 'publicationsPrimaryID' Purpose: Basic test of successful sending of an allowed value for publicationsPrimaryID Sent: Allowed value for publicationsPrimaryID Expected outcome: Resource registered with the sent value """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_publicationsPrimaryID_correct_1' sent_resource['publications'] = {'publicationsPrimaryID': '21959131'} response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get( '/tool/test_publicationsPrimaryID_correct_1', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_publicationsPrimaryID_correct_1' expected_resource['publications'] = { 'publicationsPrimaryID': '21959131', 'publicationsOtherID': [] } received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_homepage_300_length(self): """Sending 300 times character 'a' as 'homepage' Purpose: What happens when we send string of max allowed length Sent: 300 times 'a' Expected outcome: Resource registered with 300 times 'a' as a homepage """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_homepage_300_length' sent_resource['homepage'] = 'http://' + 293 * 'a' response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_homepage_300_length', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_homepage_300_length' expected_resource['homepage'] = 'http://' + 293 * 'a' received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_homepage_correct(self): """Sending a correctly formatted string as 'homepage' Purpose: Basic test of successful sending of a string as homepage Sent: homepage as a string Expected outcome: Resource registered with the sent string """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_homepage_correct' sent_resource['homepage'] = 'http://example.org' response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_homepage_correct', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_homepage_correct' expected_resource['homepage'] = 'http://example.org' received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_mirror_correct_1(self): """Sending one URL as 'mirror' Purpose: Basic test of successful sending of an allowed value for mirror Sent: Allowed value for mirror Expected outcome: Resource registered with the sent value """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_mirror_correct_1' sent_resource['mirror'] = ['http://example.org'] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_mirror_correct_1', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_mirror_correct_1' expected_resource['mirror'] = ['http://example.org'] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertItemsEqual(expected_resource, received_resource)
def test_elixirStatus_correct_1(self): """Sending one of the allowed values as 'elixirStatus' Purpose: Basic test of successful sending of an allowed value for elixirNode Sent: Allowed value for elixirNode Expected outcome: Resource registered with the sent value """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_elixirStatus_correct_1' sent_resource['elixirInfo'] = { 'elixirNode': 'Denmark', 'elixirStatus': 'ELIXIR Core Service' } response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_elixirStatus_correct_1', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_elixirStatus_correct_1' expected_resource['elixirInfo'] = { 'elixirNode': 'Denmark', 'elixirStatus': 'ELIXIR Core Service' } received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_sourceRegistry_empty_zero_length(self): """Sending string of zero length as 'sourceRegistry' Purpose: What happens when we send empty string (zero length) Sent: '' Expected outcome: Resource registered with zero-length string 'sourceRegistry' """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_sourceRegistry_zero_length' sent_resource['sourceRegistry'] = '' response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_sourceRegistry_zero_length', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_sourceRegistry_zero_length' expected_resource['sourceRegistry'] = '' received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_homepage_case_sensitive(self): """Sending camel case url as 'homepage' Purpose: What happens when we send URL with camel case Sent: Camel case URL Expected outcome: Resource registered with lowercase URL string """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_homepage_case_sensitive' sent_resource['homepage'] = 'HTTP://ExAmPlE.cOm' response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_homepage_case_sensitive', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_homepage_case_sensitive' expected_resource['homepage'] = 'HTTP://ExAmPlE.cOm' received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_sourceRegistry_dict(self): """Sending dictionary as 'sourceRegistry' Purpose: What happens when we send wrong type as the field (this case - dict of mixed types) Sent: Dictionary with mixed types (strings and arrays) Expected outcome: Resource registered with stringified dictionary. Note: Spaces are added to the stringified value. """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_sourceRegistry_dict' sent_resource['sourceRegistry'] = {'a':'b','c':[1,2,3]} response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_sourceRegistry_dict', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_sourceRegistry_dict' expected_resource['sourceRegistry'] = "{u'a': u'b', u'c': [1, 2, 3]}" received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_sourceRegistry_number(self): """Sending number as 'sourceRegistry' Purpose: What happens when we send wrong type as the field (this case - number) Sent: Number Expected outcome: Resource registered with stringified number. """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_sourceRegistry_number' sent_resource['sourceRegistry'] = 1234567890 response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_sourceRegistry_number', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_sourceRegistry_number' expected_resource['sourceRegistry'] = '1234567890' received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_Topic_Pass_URI_term(self): """Sending as 'topic': correct URI and term Purpose: Sending correct URI and term Sent: Correct URI and term Expected outcome: Resource registered - URI and term resolves to a concept """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_Topic_Pass_URI_term' sent_resource['topic'] = [{ 'uri': 'http://edamontology.org/topic_3070', 'term': 'Biology' }] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_Topic_Pass_URI_term', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_Topic_Pass_URI_term' expected_resource['topic'] = [{ 'uri': 'http://edamontology.org/topic_3070', 'term': 'Biology' }] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_topic_extra_fields(self): """Sending array of dicts with extra fields as 'topic' Purpose: What happens when we send wrong type as the field (this case - add some fields to the object) Sent: Array of arrays of mixed types Expected outcome: Resource is registered, extra fields are ignored. """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_topic_extra_fields' sent_resource['topic'] = [{ 'uri': 'http://edamontology.org/topic_3070', 'some': 'field' }] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_topic_extra_fields', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_topic_extra_fields' expected_resource['topic'] = [{ 'uri': 'http://edamontology.org/topic_3070', 'term': 'Biology' }] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_version_array(self): """Sending array as 'version' Purpose: What happens when we send wrong type as the field (this case - array of strings and arrays) Sent: Array with mixed types (strings and arrays) Expected outcome: Resource registered with stringified array. Note: Spaces are added to the stringified value. """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_version_array' sent_resource['version'] = ['a','b','c',['d']] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_version_array', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_version_array' expected_resource['version'] = "[u'a', u'b', u'c', [u'd']]" received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_collection_correct_1(self): """Sending one string as 'collection' Purpose: Basic test of successful sending of a string as collection Sent: collection as a string Expected outcome: Resource registered with the sent string """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_collection_correct_1' sent_resource['collection'] = ['Just a collection'] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_collection_correct_1', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_collection_correct_1' expected_resource['collection'] = ['Just a collection'] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertItemsEqual(expected_resource, received_resource)
def test_elixirStatus_case_sensitive(self): """Sending correct value but with wrong case as 'elixirStatus' Purpose: What happens when we send correct value but with incorrect case (elixir core service instead of ELIXIR Core Service) Sent: Value with correct string but lowercase (elixir core service instead of ELIXIR Core Service) Expected outcome: Resource registered with correct case """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_elixirStatus_case_sensitive' sent_resource['elixirInfo'] = { 'elixirNode': 'Denmark', 'elixirStatus': 'elixir core service' } response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_elixirStatus_case_sensitive', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_elixirStatus_case_sensitive' expected_resource['elixirInfo'] = { 'elixirNode': 'Denmark', 'elixirStatus': 'ELIXIR Core Service' } received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_cost_correct_3(self): """Sending one of the allowed values as 'cost' Purpose: Basic test of successful sending of an allowed value for cost Sent: Allowed value for cost Expected outcome: Resource registered with the sent value """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_cost_correct_3' sent_resource['cost'] = 'Commercial' response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_cost_correct_3', format='json') expected_resource = emptyOutputTool() expected_resource['id'] = 'test_cost_correct_3' expected_resource['cost'] = 'Commercial' received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(expected_resource, received_resource)
def test_input_dataType_Pass_URI_term(self): """Sending as 'dataType': correct URI and term Purpose: Sending correct URI and term Sent: Correct URI and term Expected outcome: Resource registered - URI and term resolves to a concept """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_input_dataType_Pass_URI_term' sent_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' }], 'input': [{ 'dataType': { 'uri': 'http://edamontology.org/data_2044', 'term': 'Sequence' } }] }] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_input_dataType_Pass_URI_term', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_input_dataType_Pass_URI_term' expected_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' }], 'functionDescription': None, 'functionHandle': None, 'input': [{ 'dataType': { 'uri': 'http://edamontology.org/data_2044', 'term': 'Sequence' }, 'dataFormat': [], 'dataHandle': None, 'dataDescription': None }], 'output': [] }] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_functionHandle_dict(self): """Sending dictionary as 'functionHandle' Purpose: What happens when we send wrong type as the field (this case - dict of mixed types) Sent: Dictionary with mixed types (strings and arrays) Expected outcome: Resource registered with stringified dictionary. Note: Spaces are added to the stringified value. """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_functionHandle_dict' sent_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': {'a':'b','c':[1,2,3]} } ] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_functionHandle_dict', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_functionHandle_dict' expected_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': "{u'a': u'b', u'c': [1, 2, 3]}", 'functionDescription': None, 'input': [], 'output': [] } ] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_functionHandle_correct(self): """Sending string as 'functionHandle' Purpose: Basic test of successful sending of a string as description Sent: description as a string Expected outcome: Resource registered with the sent string """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_functionHandle_correct' sent_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': 'Just a functionHandle' } ] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_functionHandle_correct', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_functionHandle_correct' expected_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': 'Just a functionHandle', 'functionDescription': None, 'input': [], 'output': [] } ] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_functionHandle_300_length(self): """Sending 300 times character 'a' as 'functionHandle' Purpose: What happens when we send string of max allowed length Sent: 300 times 'a' Expected outcome: Resource registered with 300 times 'a' as a description """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_functionHandle_300_length' sent_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': 300*'a' } ] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_functionHandle_300_length', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_functionHandle_300_length' expected_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': 300*'a', 'functionDescription': None, 'input': [], 'output': [] } ] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_operation_Pass_2_operations(self): """Sending as 'operation': 2 objects Purpose: Sending 2 operation objects to test if saving multiple operations works Sent: 2 correct URI/term pairs Expected outcome: Resource registered with 2 operations """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_operation_Pass_2_operations' sent_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' }, { 'uri': 'http://edamontology.org/operation_0227', 'term': 'Indexing' }] }] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_operation_Pass_2_operations', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_operation_Pass_2_operations' expected_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' }, { 'uri': 'http://edamontology.org/operation_0227', 'term': 'Indexing' }], 'functionDescription': None, 'functionHandle': None, 'input': [], 'output': [] }] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertItemsEqual(expected_resource, received_resource)
def test_functionHandle_non_ascii(self): """Sending string with non-ascii characters as 'functionHandle' Purpose: What happens when we send non-ascii characters Sent: String with non-ascii characters Expected outcome: Resource registered with the non-ascii characters """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_functionHandle_non_ascii' sent_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': u'ąęćżźń£ Ø Δ ♥ †' } ] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_functionHandle_non_ascii', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_functionHandle_non_ascii' expected_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': u'ąęćżźń£ Ø Δ ♥ †', 'functionDescription': None, 'input': [], 'output': [] } ] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_functionHandle_number(self): """Sending number as 'functionHandle' Purpose: What happens when we send wrong type as the field (this case - number) Sent: Number Expected outcome: Resource registered with stringified number. """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_functionHandle_number' sent_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': 1234567890 } ] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_functionHandle_number', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_functionHandle_number' expected_resource['function'] = [ { 'operation': [ { 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' } ], 'functionHandle': '1234567890', 'functionDescription': None, 'input': [], 'output': [] } ] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertEqual(expected_resource, received_resource)
def test_operation_duplicate(self): """Sending two identical strings as 'operation' Purpose: Checking if the system will remove duplicate elements Sent: Two identical operation strings Expected outcome: Resource registered without the duplicate string """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_operation_duplicate' sent_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004' }, { 'uri': 'http://edamontology.org/operation_0004' }] }] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_operation_duplicate', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_operation_duplicate' expected_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' }], 'functionDescription': None, 'functionHandle': None, 'input': [], 'output': [] }] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertItemsEqual(expected_resource, received_resource)
def test_operation_Pass_URI_only(self): """Sending as 'operation': correct URI Purpose: Sending correct URI Sent: Correct URI Expected outcome: Resource registered - URI resolves to a concept, term filled in """ sent_resource = emptyInputTool() sent_resource['id'] = 'test_operation_Pass_URI_only' sent_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004' }] }] response = self.client.post('/tool/', sent_resource, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) response = self.client.get('/tool/test_operation_Pass_URI_only', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) expected_resource = emptyOutputTool() expected_resource['id'] = 'test_operation_Pass_URI_only' expected_resource['function'] = [{ 'operation': [{ 'uri': 'http://edamontology.org/operation_0004', 'term': 'Operation' }], 'functionDescription': None, 'functionHandle': None, 'input': [], 'output': [] }] received_resource = json.loads(response.content) received_resource['additionDate'] = None received_resource['lastUpdate'] = None self.assertItemsEqual(expected_resource, received_resource)