def test_01_detect_verify_type(self):
     pdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "plugins", "test_workflow", "test_01")
     plugin.PluginFactory.load_from_directory(plugin_dir=pdir)
     print plugin.PluginFactory.PLUGIN_CONFIG
     
     # check that we can identify a doi
     record = {"identifier" : {"id" : "10.blah"}}
     record = models.MessageObject(record=record)
     workflow._detect_verify_type(record)
     record = record.record
     assert record["identifier"]["type"] == "doi"
     
     # check we can identify a pmid
     record = {"identifier" : {"id" : "12345678"}}
     record = models.MessageObject(record=record)
     workflow._detect_verify_type(record)
     record = record.record
     print record
     assert record["identifier"]["type"] == "pmid", record
     
     # check that we can deal with a lookup exception
     record = {"identifier" : {"id" : "123456789", "type" : "doi"}}
     record = models.MessageObject(record=record)
     with self.assertRaises(models.LookupException):
         workflow._detect_verify_type(record)
     
     # check that we can deal with an unidentifiable identifier
     record = {"identifier" : {"id" : "abcd"}}
     record = models.MessageObject(record=record)
     workflow._detect_verify_type(record)
     record = record.record
     assert not record["identifier"].has_key("type")
 def test_01_detect_verify_type(self):
     config.type_detection = ["mock_doi_type", "mock_pmid_type"]
     
     # check that we can identify a doi
     record = {"identifier" : {"id" : "10.blah"}}
     workflow._detect_verify_type(record)
     assert record["identifier"]["type"] == "doi"
     
     # check we can identify a pmid
     record = {"identifier" : {"id" : "12345678"}}
     workflow._detect_verify_type(record)
     assert record["identifier"]["type"] == "pmid"
     
     # check that we can deal with a lookup exception
     record = {"identifier" : {"id" : "123456789", "type" : "doi"}}
     with self.assertRaises(model_exceptions.LookupException):
         workflow._detect_verify_type(record)
     
     # check that we can deal with an unidentifiable identifier
     record = {"identifier" : {"id" : "abcd"}}
     workflow._detect_verify_type(record)
     assert not record["identifier"].has_key("type")