def test_make_clusters_new_signatures(): """Test if signatures will be allocated in bucket for new signatures. This test checks if new signatures will be clustered together, and then put in the second bucket, which contains new signatures. """ from beard_server.tasks import make_clusters records = [ { "title": "Towards graphene-based detectors for" + " dark matter directional detection", "year": 2015, "publication_id": 1395222, "authors": [ "Wang, Shang-Yung" ] }, { "title": "Induced Einstein-Kalb-Ramond theory and" + " the black hole", "year": 1996, "publication_id": 428605, "authors": [ "Kao, W.F.", "Chyi, Tzuu-Kang", "Dai, W.B.", "Wang, Shang-Yung", "Lin, Shih-Yuun" ] } ] signatures = [ { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Wang, Shang-Yung", "publication_id": 1395222, "signature_id": "Wang_1395222", }, { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Wang, Shang-Yung", "publication_id": 428605, "signature_id": "Wang_428605", }, { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Lin, Shih-Yuin", "publication_id": 428605, "signature_id": "Lin_428605", } ] # Bucket with new clusters only. result = ({}, {'0': ['Lin_428605'], '1': ['Wang_1395222', 'Wang_428605']}) assert make_clusters(records, signatures) == result
def test_make_clusters_profile_exists(): """Test if signatures will be allocated in bucket for matched signatures. This test checks if signatures, which already have profiles will be clustered together, and then put in the first bucket, which contains signatures matched by recid and Beard together. """ from beard_server.tasks import make_clusters records = [{ "title": "Towards graphene-based detectors for" + " dark matter directional detection", "year": 2015, "publication_id": 1395222, "authors": ["Wang, Shang-Yung"] }, { "title": "Induced Einstein-Kalb-Ramond theory and" + " the black hole", "year": 1996, "publication_id": 428605, "authors": [ "Kao, W.F.", "Chyi, Tzuu-Kang", "Dai, W.B.", "Wang, Shang-Yung", "Lin, Shih-Yuun" ] }] signatures = [{ "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Wang, Shang-Yung", "publication_id": 1395222, "signature_id": "Wang_1395222", "author_recid": "A", }, { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Wang, Shang-Yung", "publication_id": 428605, "signature_id": "Wang_428605", "author_recid": "A", }, { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Lin, Shih-Yuin", "publication_id": 428605, "signature_id": "Lin_428605", "author_recid": "B", }] # Bucket with old clusters only. result = ({'A': ['Wang_1395222', 'Wang_428605'], 'B': ['Lin_428605']}, {}) assert make_clusters(records, signatures) == result
def test_make_clusters_profile_exists_new_arrives(): """Test if signatures will be allocated in buckets for matched and new signatures. This test checks what will happen if a system already has some signatures with profiles assigned to them and a new signature is arriving. The output should show two signatures clustered together in "old" bucket and a new signature in the bucket for new data. """ from beard_server.tasks import make_clusters records = [{ "title": "Towards graphene-based detectors for" + " dark matter directional detection", "year": 2015, "publication_id": 1395222, "authors": ["Wang, Shang-Yung"] }, { "title": "Induced Einstein-Kalb-Ramond theory and" + " the black hole", "year": 1996, "publication_id": 428605, "authors": [ "Kao, W.F.", "Chyi, Tzuu-Kang", "Dai, W.B.", "Wang, Shang-Yung", "Lin, Shih-Yuun" ] }] signatures = [{ "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Wang, Shang-Yung", "publication_id": 1395222, "signature_id": "Wang_1395222", "author_recid": "A", }, { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Wang, Shang-Yung", "publication_id": 428605, "signature_id": "Wang_428605", "author_recid": "A", }, { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Lin, Shih-Yuin", "publication_id": 428605, "signature_id": "Lin_428605", }] # Bucket with old clusters only. result = ({'A': ['Wang_1395222', 'Wang_428605']}, {'0': ['Lin_428605']}) assert make_clusters(records, signatures) == result
def test_make_clusters_profile_exists_new_arrives(): """Test if signatures will be allocated in buckets for matched and new signatures. This test checks what will happen if a system already has some signatures with profiles assigned to them and a new signature is arriving. The output should show two signatures clustered together in "old" bucket and a new signature in the bucket for new data. """ from beard_server.tasks import make_clusters records = [ { "title": "Towards graphene-based detectors for" + " dark matter directional detection", "year": 2015, "publication_id": 1395222, "authors": [ "Wang, Shang-Yung" ] }, { "title": "Induced Einstein-Kalb-Ramond theory and" + " the black hole", "year": 1996, "publication_id": 428605, "authors": [ "Kao, W.F.", "Chyi, Tzuu-Kang", "Dai, W.B.", "Wang, Shang-Yung", "Lin, Shih-Yuun" ] } ] signatures = [ { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Wang, Shang-Yung", "publication_id": 1395222, "signature_id": "Wang_1395222", "author_recid": "A", }, { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Wang, Shang-Yung", "publication_id": 428605, "signature_id": "Wang_428605", "author_recid": "A", }, { "author_affiliation": "Taiwan, Natl. Chiao Tung U.", "author_name": "Lin, Shih-Yuin", "publication_id": 428605, "signature_id": "Lin_428605", } ] # Bucket with old clusters only. result = ({'A': ['Wang_1395222', 'Wang_428605']}, {'0': ['Lin_428605']}) assert make_clusters(records, signatures) == result