def test_add_metrics_data(self): item = {'created': '2012-08-23T14:40:16.399932', '_rev': '6-3e0ede6e797af40860e9dadfb39056ce', 'last_modified': '2012-08-23T14:40:16.399932', 'biblio': {'title': 'Perceptual training strongly improves visual motion perception in schizophrenia', 'journal': 'Brain and Cognition', 'year': 2011, 'authors': u'Norton, McBain, \xd6ng\xfcr, Chen'}, '_id': '4mlln04q1rxy6l9oeb3t7ftv', 'type': 'item', 'aliases': {'url': ['http://linkinghub.elsevier.com/retrieve/pii/S0278262611001308', 'http://www.ncbi.nlm.nih.gov/pubmed/21872380'], 'pmid': ['21872380'], 'doi': ['10.1016/j.bandc.2011.08.003'], 'title': ['Perceptual training strongly improves visual motion perception in schizophrenia']}} metrics_method_response = (2, 'http://api.mendeley.com/research/perceptual-training-strongly-improves-visual-motion-perception-schizophrenia/') response = item_module.add_metrics_data("mendeley:readers", metrics_method_response, item) print json.dumps(response, sort_keys=True, indent=4) assert_equals(response["metrics"]["mendeley:readers"]["values"]["raw"], 2) assert_equals(response["metrics"]["mendeley:readers"]["values"]["raw_history"].values(), [2]) assert_equals(response["metrics"]["mendeley:readers"]["provenance_url"], 'http://api.mendeley.com/research/perceptual-training-strongly-improves-visual-motion-perception-schizophrenia/')
def update_item_with_new_metrics(cls, metric_name, metrics_method_response, item_doc): item_doc = item_module.add_metrics_data(metric_name, metrics_method_response, item_doc) item_obj = item_module.add_metric_to_item_object( metric_name, metrics_method_response, item_doc) return (item_doc)
def update_item_with_new_metrics(cls, metric_name, metrics_method_response, item_doc): item_doc = item_module.add_metrics_data(metric_name, metrics_method_response, item_doc) item_obj = item_module.add_metric_to_item_object(metric_name, metrics_method_response, item_doc) return(item_doc)