• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

adsabs / ADSCitationCapture / 15909488557

26 Jun 2025 06:20PM UTC coverage: 70.171% (-0.04%) from 70.21%
15909488557

Pull #73

github

web-flow
Merge 1270afe42 into 57448c851
Pull Request #73: Allow reparsing of metadata without re-harvesting.

1 of 5 new or added lines in 1 file covered. (20.0%)

26 existing lines in 3 files now uncovered.

2510 of 3577 relevant lines covered (70.17%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.41
/ADSCitationCapture/tests/test_forward.py
1
import sys
1✔
2
import os
1✔
3
import json
1✔
4
import adsmsg
1✔
5
from ADSCitationCapture import webhook
1✔
6
from ADSCitationCapture import doi
1✔
7
from ADSCitationCapture import url
1✔
8
from ADSCitationCapture import db
1✔
9
from ADSCitationCapture import forward
1✔
10
from adsmsg import DenormalizedRecord
1✔
11
from .test_base import TestBase
1✔
12

13
import unittest
1✔
14
from ADSCitationCapture import app, tasks
1✔
15
from mock import patch
1✔
16

17

18
class TestWorkers(TestBase):
1✔
19

20
    def _common_citation_changes_doi(self, status):
1✔
21
        citation_changes = adsmsg.CitationChanges()
1✔
22
        citation_change = citation_changes.changes.add()
1✔
23
        citation_change.citing = '2005CaJES..42.1987P'
1✔
24
        citation_change.cited = '...................'
1✔
25
        citation_change.content = '10.5281/zenodo.11020'
1✔
26
        citation_change.content_type = adsmsg.CitationChangeContentType.doi
1✔
27
        citation_change.resolved = False
1✔
28
        citation_change.status = status
1✔
29
        return citation_changes
1✔
30

31
    def setUp(self):
1✔
32
        TestBase.setUp(self)
1✔
33

34
    def tearDown(self):
1✔
35
        TestBase.tearDown(self)
1✔
36
        
37
    def test_build_bib_record_no_associated_works(self):
1✔
38
        content_filename = os.path.join(self.app.conf['PROJ_HOME'], "ADSCitationCapture/tests/data/sample_bib_record.json")
1✔
39
        with open(content_filename) as f:
1✔
40
            expect_bib_record = json.load(f)
1✔
41
        content_filename = os.path.join(self.app.conf['PROJ_HOME'], "ADSCitationCapture/tests/data/sample_nonbib_record.json")
1✔
42
        with open(content_filename) as f:
1✔
43
            expect_nonbib_record = json.load(f)
1✔
44

45
        citation_changes = self._common_citation_changes_doi(adsmsg.Status.updated)
1✔
46
        citation_change = tasks._protobuf_to_adsmsg_citation_change(citation_changes.changes[0])
1✔
47
        doi_id = "10.5281/zenodo.11020" # software
1✔
48
        parsed_metadata = self.mock_data[doi_id]['parsed']
1✔
49
        citations =['']
1✔
50
        db_versions = {"":""}
1✔
51
        bib_record, nonbib_record = forward.build_record(self.app, citation_change, parsed_metadata, citations, db_versions)  
1✔
52
        self.assertEqual(bib_record.toJSON(),expect_bib_record)
1✔
53
        self.assertEqual(nonbib_record.toJSON(),expect_nonbib_record)
1✔
54

55
    def test_build_bib_record_associated_works(self):
1✔
56
        content_filename = os.path.join(self.app.conf['PROJ_HOME'], "ADSCitationCapture/tests/data/sample_bib_record_associated.json")
1✔
57
        with open(content_filename) as f:
1✔
58
            expect_bib_record = json.load(f)
1✔
59
        content_filename = os.path.join(self.app.conf['PROJ_HOME'], "ADSCitationCapture/tests/data/sample_nonbib_record_associated.json")
1✔
60
        with open(content_filename) as f:
1✔
61
            expect_nonbib_record = json.load(f)
1✔
62

63
        citation_changes = self._common_citation_changes_doi(adsmsg.Status.updated)
1✔
64
        citation_change = tasks._protobuf_to_adsmsg_citation_change(citation_changes.changes[0])
1✔
65
        doi_id = "10.5281/zenodo.4475376" # software
1✔
66
        parsed_metadata = self.mock_data[doi_id]['parsed']
1✔
67
        citations =['']
1✔
68
        db_versions = self.mock_data[doi_id]['associated']
1✔
69
        bib_record, nonbib_record = forward.build_record(self.app, citation_change, parsed_metadata, citations, db_versions)  
1✔
70
        
71
        self.assertEqual(bib_record.toJSON(),expect_bib_record)
1✔
72
        self.assertEqual(nonbib_record.toJSON(),expect_nonbib_record)
1✔
73
if __name__ == '__main__':
1✔
UNCOV
74
    unittest.main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc