def test_ascl_deleted_citation_with_bibcode(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '2017AJ....153..114F'
        citation_change.cited = '2012ascl.soft03003C'
        citation_change.content = 'ascl:1203.003'
        citation_change.content_type = adsmsg.CitationChangeContentType.pid
        citation_change.resolved = True
        citation_change.status = adsmsg.Status.deleted
        expected_event_type = "relation_deleted"
        expected_original_relationship_name = "Cites"
        expected_source_bibcode = citation_change.citing
        expected_target_id = citation_change.content
        expected_target_id_schema = "ascl"
        expected_target_url = "https://ascl.net/{}".format(expected_target_id)
        expected_json_body = self._build_expected_json_body(
            expected_event_type, expected_original_relationship_name,
            expected_source_bibcode, expected_target_id,
            expected_target_id_schema, expected_target_url)

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                     self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                     event_data,
                                     timeout=30)
        self.assertFalse(
            emitted,
            "Agreed citation change was NOT assigned to an agreed event")
    def test_doi_deleted_citation_with_bibcode(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '2000JMP....41.1788O'
        citation_change.cited = '1990JMP....31..316D'
        citation_change.content = '10.1063/1.528916'
        citation_change.content_type = adsmsg.CitationChangeContentType.doi
        citation_change.resolved = True
        citation_change.status = adsmsg.Status.deleted
        expected_event_type = "relation_deleted"
        expected_original_relationship_name = "Cites"
        expected_source_bibcode = citation_change.citing
        expected_target_id = citation_change.content
        expected_target_id_schema = "doi"
        expected_target_url = "https://doi.org/{}".format(expected_target_id)
        expected_json_body = self._build_expected_json_body(
            expected_event_type, expected_original_relationship_name,
            expected_source_bibcode, expected_target_id,
            expected_target_id_schema, expected_target_url)

        event_data = webhook.citation_change_to_event_data(
            citation_change, expected_json_body)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                     self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                     event_data,
                                     timeout=30)
        self.assertTrue(
            emitted,
            "Agreed citation change was NOT assigned to an agreed event")
        request = httpretty.last_request()
        self._assert_request(request, expected_json_body)
    def test_doi_new_citation(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '2005CaJES..42.1987P'
        citation_change.cited = '...................'
        citation_change.content = '10.1016/0277-3791'
        citation_change.content_type = adsmsg.CitationChangeContentType.doi
        citation_change.resolved = False
        citation_change.status = adsmsg.Status.new
        expected_event_type = "relation_created"
        expected_original_relationship_name = "Cites"
        expected_source_bibcode = citation_change.citing
        expected_target_id = citation_change.content
        expected_target_id_schema = u"DOI"
        expected_target_url = "https://doi.org"
        expected_json_body = self._build_expected_json_body(
            expected_event_type, expected_original_relationship_name,
            expected_source_bibcode, expected_target_id,
            expected_target_id_schema, expected_target_url)

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                     self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                     event_data,
                                     timeout=30)
        self.assertTrue(
            emitted,
            "Agreed citation change was NOT assigned to an agreed event")
        request = httpretty.last_request()
        self._assert_request(request, expected_json_body)
    def test_url_new_citation_with_bibcode(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '2017arXiv170305698M'
        citation_change.cited = '2017iagt.conf.2017G'
        citation_change.content = 'http://www.github.com/capergroup/bayou'
        citation_change.content_type = adsmsg.CitationChangeContentType.url
        citation_change.resolved = True
        citation_change.status = adsmsg.Status.new
        expected_event_type = "relation_created"
        expected_original_relationship_name = "Cites"
        expected_source_bibcode = citation_change.citing
        expected_target_id = citation_change.content
        expected_target_id_schema = u"URL"
        expected_target_url = citation_change.content
        expected_json_body = self._build_expected_json_body(
            expected_event_type, expected_original_relationship_name,
            expected_source_bibcode, expected_target_id,
            expected_target_id_schema, expected_target_url)

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                     self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                     event_data,
                                     timeout=30)
        self.assertTrue(
            emitted,
            "Agreed citation change was NOT assigned to an agreed event")
        request = httpretty.last_request()
        self._assert_request(request, expected_json_body)
    def test_url_updated_citation_with_bibcode(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '2016NatSR...637369S'
        citation_change.cited = '2012JOSS...61..539R'  # previous_cited 2012ASSL..304..539R
        citation_change.content = 'http://mrbayes.sourceforge.net/'
        citation_change.content_type = adsmsg.CitationChangeContentType.url
        citation_change.resolved = True
        citation_change.status = adsmsg.Status.updated
        expected_event_type = "relation_created"
        expected_original_relationship_name = "IsIdenticalTo"
        expected_source_bibcode = citation_change.cited
        expected_target_id = citation_change.content
        expected_target_id_schema = u"URL"
        expected_target_url = citation_change.content
        expected_json_body = self._build_expected_json_body(
            expected_event_type, expected_original_relationship_name,
            expected_source_bibcode, expected_target_id,
            expected_target_id_schema, expected_target_url)

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                     self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                     event_data,
                                     timeout=30)
        self.assertFalse(
            emitted,
            "Agreed citation change was NOT assigned to an agreed event")
    def test_ascl_new_citation_with_bibcode(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '2017A&A...603A.117S'
        citation_change.cited = '2011ascl.soft06002P'
        citation_change.content = 'ascl:1106.002'
        citation_change.content_type = adsmsg.CitationChangeContentType.pid
        citation_change.resolved = True
        citation_change.status = adsmsg.Status.new
        expected_event_type = "relation_created"
        expected_original_relationship_name = "Cites"
        expected_source_bibcode = citation_change.citing
        expected_target_id = citation_change.content
        expected_target_id_schema = u"ASCL"
        expected_target_url = "http://ascl.net/"
        expected_json_body = self._build_expected_json_body(
            expected_event_type, expected_original_relationship_name,
            expected_source_bibcode, expected_target_id,
            expected_target_id_schema, expected_target_url)

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                     self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                     event_data,
                                     timeout=30)
        self.assertTrue(
            emitted,
            "Agreed citation change was NOT assigned to an agreed event")
        request = httpretty.last_request()
        self._assert_request(request, expected_json_body)
    def test_ascl_deleted_citation(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = ''
        citation_change.cited = '...................'
        citation_change.content = ''
        citation_change.content_type = adsmsg.CitationChangeContentType.pid
        citation_change.resolved = False
        citation_change.status = adsmsg.Status.deleted
        expected_event_type = "relation_deleted"
        expected_original_relationship_name = "Cites"
        expected_source_bibcode = citation_change.citing
        expected_target_id = citation_change.content
        expected_target_id_schema = u"ASCL"
        expected_target_url = "http://ascl.net/"
        expected_json_body = self._build_expected_json_body(
            expected_event_type, expected_original_relationship_name,
            expected_source_bibcode, expected_target_id,
            expected_target_id_schema, expected_target_url)

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                     self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                     event_data,
                                     timeout=30)
        self.assertFalse(
            emitted,
            "Agreed citation change was NOT assigned to an agreed event")
    def test_doi_updated_citation_with_bibcode(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '1998CP....232..343L'
        citation_change.content = '1991SPIE.1361.1048S'
        citation_change.content_type = adsmsg.CitationChangeContentType.doi
        citation_change.resolved = True
        citation_change.status = adsmsg.Status.updated
        expected_event_type = "relation_created"
        expected_original_relationship_name = "IsIdenticalTo"
        expected_source_bibcode = citation_change.cited
        expected_target_id = citation_change.content
        expected_target_id_schema = u"DOI"
        expected_target_url = "https://doi.org"
        expected_json_body = self._build_expected_json_body(
            expected_event_type, expected_original_relationship_name,
            expected_source_bibcode, expected_target_id,
            expected_target_id_schema, expected_target_url)

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                     self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                     event_data,
                                     timeout=30)
        self.assertFalse(
            emitted,
            "Agreed citation change was NOT assigned to an agreed event")
 def test_url_updated_citation(self):
     citation_changes = adsmsg.CitationChanges()
     citation_change = citation_changes.changes.add()
     citation_change.citing = '2016CMAME.305..579P'
     citation_change.cited = '...................'  # previous_cited 2015LIACo...3....2T
     citation_change.content = 'https://github.com/su2code/TestCases'
     citation_change.content_type = adsmsg.CitationChangeContentType.url
     citation_change.resolved = False
     citation_change.status = adsmsg.Status.updated
     is_link_alive = False
     license_info = {
         'license_url': 'https://creativecommons.org/publicdomain/zero/1.0/'
     }
     parsed_metadata = {
         'link_alive': is_link_alive,
         "doctype": "software",
         'license_name': license_info.get('license_name', ""),
         'license_url': license_info.get('license_url', "")
     }
     event_data = webhook.citation_change_to_event_data(
         citation_change, parsed_metadata)
     emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                  self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                  event_data,
                                  timeout=30)
     self.assertFalse(
         emitted,
         "Non-agreed citation change was assigned to an agreed event")
 def test_ascl_updated_citation(self):
     citation_changes = adsmsg.CitationChanges()
     citation_change = citation_changes.changes.add()
     citation_change.citing = '2013MNRAS.432.1658C'
     citation_change.cited = '...................'  # previous_cited 2012ascl.soft05004P
     citation_change.content = 'ascl:1205.004'
     citation_change.content_type = adsmsg.CitationChangeContentType.pid
     citation_change.resolved = False
     citation_change.status = adsmsg.Status.updated
     is_link_alive = False
     license_info = {
         'license_url': 'https://creativecommons.org/publicdomain/zero/1.0/'
     }
     parsed_metadata = {
         'link_alive': is_link_alive,
         "doctype": "software",
         'license_name': license_info.get('license_name', ""),
         'license_url': license_info.get('license_url', "")
     }
     event_data = webhook.citation_change_to_event_data(
         citation_change, parsed_metadata)
     emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                  self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                  event_data,
                                  timeout=30)
     self.assertFalse(
         emitted,
         "Non-agreed citation change was assigned to an agreed event")
 def test_doi_updated_citation(self):
     citation_changes = adsmsg.CitationChanges()
     citation_change = citation_changes.changes.add()
     citation_change.citing = '1999ITGRS..37..917L'
     citation_change.cited = '...................'  # previous_cited 1997ASAJ..101Q3182L
     citation_change.content = '10.1121/1.419176'
     citation_change.content_type = adsmsg.CitationChangeContentType.doi
     citation_change.resolved = False
     citation_change.status = adsmsg.Status.updated
     is_link_alive = False
     license_info = {
         'license_url': 'https://creativecommons.org/publicdomain/zero/1.0/'
     }
     parsed_metadata = {
         'link_alive': is_link_alive,
         "doctype": "software",
         'license_name': license_info.get('license_name', ""),
         'license_url': license_info.get('license_url', "")
     }
     event_data = webhook.citation_change_to_event_data(
         citation_change, parsed_metadata)
     emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                  self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                  event_data,
                                  timeout=30)
     self.assertFalse(
         emitted,
         "Non-agreed citation change was assigned to an agreed event")
Exemple #12
0
 def test_url_updated_citation(self):
     citation_changes = adsmsg.CitationChanges()
     citation_change = citation_changes.changes.add()
     citation_change.citing = '2016CMAME.305..579P'
     citation_change.cited = '...................' # previous_cited 2015LIACo...3....2T
     citation_change.content = 'https://github.com/su2code/TestCases'
     citation_change.content_type = adsmsg.CitationChangeContentType.url
     citation_change.resolved = False
     citation_change.status = adsmsg.Status.updated
     event_data = webhook.citation_change_to_event_data(citation_change)
     emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'], self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'], event_data, timeout=30)
     self.assertFalse(emitted, "Non-agreed citation change was assigned to an agreed event")
Exemple #13
0
    def test_ascl_updated_citation(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '2013MNRAS.432.1658C'
        citation_change.cited = '...................' # previous_cited 2012ascl.soft05004P
        citation_change.content = 'ascl:1205.004'
        citation_change.content_type = adsmsg.CitationChangeContentType.pid
        citation_change.resolved = False
        citation_change.status = adsmsg.Status.updated

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'], self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'], event_data, timeout=30)
        self.assertFalse(emitted, "Non-agreed citation change was assigned to an agreed event")
Exemple #14
0
    def test_doi_updated_citation(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '1999ITGRS..37..917L'
        citation_change.cited = '...................' # previous_cited 1997ASAJ..101Q3182L
        citation_change.content = '10.1121/1.419176'
        citation_change.content_type = adsmsg.CitationChangeContentType.doi
        citation_change.resolved = False
        citation_change.status = adsmsg.Status.updated

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'], self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'], event_data, timeout=30)
        self.assertFalse(emitted, "Non-agreed citation change was assigned to an agreed event")
 def test_doi_new_citation(self):
     citation_changes = adsmsg.CitationChanges()
     citation_change = citation_changes.changes.add()
     citation_change.citing = '2005CaJES..42.1987P'
     citation_change.cited = '...................'
     citation_change.content = '10.1016/0277-3791'
     citation_change.content_type = adsmsg.CitationChangeContentType.doi
     citation_change.resolved = False
     citation_change.status = adsmsg.Status.new
     expected_event_type = "relation_created"
     expected_original_relationship_name = "Cites"
     expected_source_bibcode = citation_change.citing
     expected_target_id = citation_change.content
     expected_target_id_schema = "doi"
     expected_target_url = "https://doi.org/{}".format(expected_target_id)
     is_link_alive = True
     license_info = {
         'license_url': 'https://creativecommons.org/publicdomain/zero/1.0/'
     }
     parsed_metadata = {
         'link_alive': is_link_alive,
         "doctype": "software",
         'license_name': license_info.get('license_name', ""),
         'license_url': license_info.get('license_url', "")
     }
     expected_json_body = self._build_expected_json_body(
         expected_event_type, expected_original_relationship_name,
         expected_source_bibcode, expected_target_id,
         expected_target_id_schema, expected_target_url,
         parsed_metadata.get('doctype', ""),
         parsed_metadata.get('license_url', ""))
     event_data = webhook.citation_change_to_event_data(
         citation_change, parsed_metadata)
     emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                  self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                  event_data,
                                  timeout=30)
     self.assertTrue(
         emitted,
         "Agreed citation change was NOT assigned to an agreed event")
     request = httpretty.last_request()
     self._assert_request(request, expected_json_body)
 def test_url_new_citation_with_bibcode(self):
     citation_changes = adsmsg.CitationChanges()
     citation_change = citation_changes.changes.add()
     citation_change.citing = '2017arXiv170305698M'
     citation_change.cited = '2017iagt.conf.2017G'
     citation_change.content = 'http://www.github.com/capergroup/bayou'
     citation_change.content_type = adsmsg.CitationChangeContentType.url
     citation_change.resolved = True
     citation_change.status = adsmsg.Status.new
     expected_event_type = "relation_created"
     expected_original_relationship_name = "Cites"
     expected_source_bibcode = citation_change.citing
     expected_target_id = citation_change.content
     expected_target_id_schema = "url"
     expected_target_url = citation_change.content
     is_link_alive = True
     license_info = {
         'license_url': 'https://creativecommons.org/publicdomain/zero/1.0/'
     }
     parsed_metadata = {
         'link_alive': is_link_alive,
         "doctype": "software",
         'license_name': license_info.get('license_name', ""),
         'license_url': license_info.get('license_url', "")
     }
     expected_json_body = self._build_expected_json_body(
         expected_event_type, expected_original_relationship_name,
         expected_source_bibcode, expected_target_id,
         expected_target_id_schema, expected_target_url,
         parsed_metadata.get('doctype', ""),
         parsed_metadata.get('license_url', ""))
     event_data = webhook.citation_change_to_event_data(
         citation_change, parsed_metadata)
     emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                  self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                  event_data,
                                  timeout=30)
     self.assertTrue(
         emitted,
         "Agreed citation change was NOT assigned to an agreed event")
     request = httpretty.last_request()
     self._assert_request(request, expected_json_body)
 def test_url_updated_citation_with_bibcode(self):
     citation_changes = adsmsg.CitationChanges()
     citation_change = citation_changes.changes.add()
     citation_change.citing = '2016NatSR...637369S'
     citation_change.cited = '2012JOSS...61..539R'  # previous_cited 2012ASSL..304..539R
     citation_change.content = 'http://mrbayes.sourceforge.net/'
     citation_change.content_type = adsmsg.CitationChangeContentType.url
     citation_change.resolved = True
     citation_change.status = adsmsg.Status.updated
     expected_event_type = "relation_created"
     expected_original_relationship_name = "IsIdenticalTo"
     expected_source_bibcode = citation_change.cited
     expected_target_id = citation_change.content
     expected_target_id_schema = "url"
     expected_target_url = citation_change.content
     is_link_alive = True
     license_info = {
         'license_url': 'https://creativecommons.org/publicdomain/zero/1.0/'
     }
     parsed_metadata = {
         'link_alive': is_link_alive,
         "doctype": "software",
         'license_name': license_info.get('license_name', ""),
         'license_url': license_info.get('license_url', "")
     }
     expected_json_body = self._build_expected_json_body(
         expected_event_type, expected_original_relationship_name,
         expected_source_bibcode, expected_target_id,
         expected_target_id_schema, expected_target_url,
         parsed_metadata.get('doctype', ""),
         parsed_metadata.get('license_url', ""))
     event_data = webhook.citation_change_to_event_data(
         citation_change, parsed_metadata)
     emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                  self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                  event_data,
                                  timeout=30)
     self.assertFalse(
         emitted,
         "Agreed citation change was NOT assigned to an agreed event")
Exemple #18
0
    def test_url_new_citation(self):
        citation_changes = adsmsg.CitationChanges()
        citation_change = citation_changes.changes.add()
        citation_change.citing = '2017arXiv170610086M'
        citation_change.cited = '...................'
        citation_change.content = 'https://github.com/ComputationalRadiationPhysics/graybat'
        citation_change.content_type = adsmsg.CitationChangeContentType.url
        citation_change.resolved = False
        citation_change.status = adsmsg.Status.new
        expected_event_type = "relation_created"
        expected_original_relationship_name = "Cites"
        expected_source_bibcode = citation_change.citing
        expected_target_id = citation_change.content
        expected_target_id_schema = u"url"
        expected_target_url = citation_change.content
        expected_json_body = self._build_expected_json_body(expected_event_type, expected_original_relationship_name, expected_source_bibcode, expected_target_id, expected_target_id_schema, expected_target_url)

        event_data = webhook.citation_change_to_event_data(citation_change)
        emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'], self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'], event_data, timeout=30)
        self.assertTrue(emitted, "Agreed citation change was NOT assigned to an agreed event")
        request = httpretty.last_request()
        self._assert_request(request, expected_json_body)
 def test_doi_updated_citation_with_bibcode(self):
     citation_changes = adsmsg.CitationChanges()
     citation_change = citation_changes.changes.add()
     citation_change.citing = '1998CP....232..343L'
     citation_change.content = '1991SPIE.1361.1048S'
     citation_change.content_type = adsmsg.CitationChangeContentType.doi
     citation_change.resolved = True
     citation_change.status = adsmsg.Status.updated
     expected_event_type = "relation_created"
     expected_original_relationship_name = "IsIdenticalTo"
     expected_source_bibcode = citation_change.cited
     expected_target_id = citation_change.content
     expected_target_id_schema = "doi"
     expected_target_url = "https://doi.org/{}".format(expected_target_id)
     is_link_alive = True
     license_info = {
         'license_url': 'https://creativecommons.org/publicdomain/zero/1.0/'
     }
     parsed_metadata = {
         'link_alive': is_link_alive,
         "doctype": "software",
         'license_name': license_info.get('license_name', ""),
         'license_url': license_info.get('license_url', "")
     }
     expected_json_body = self._build_expected_json_body(
         expected_event_type, expected_original_relationship_name,
         expected_source_bibcode, expected_target_id,
         expected_target_id_schema, expected_target_url,
         parsed_metadata.get('doctype', ""),
         parsed_metadata.get('license_url', ""))
     event_data = webhook.citation_change_to_event_data(
         citation_change, parsed_metadata)
     emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                  self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                  event_data,
                                  timeout=30)
     self.assertFalse(
         emitted,
         "Agreed citation change was NOT assigned to an agreed event")
 def test_ascl_deleted_citation(self):
     citation_changes = adsmsg.CitationChanges()
     citation_change = citation_changes.changes.add()
     citation_change.citing = ''
     citation_change.cited = '...................'
     citation_change.content = ''
     citation_change.content_type = adsmsg.CitationChangeContentType.pid
     citation_change.resolved = False
     citation_change.status = adsmsg.Status.deleted
     expected_event_type = "relation_deleted"
     expected_original_relationship_name = "Cites"
     expected_source_bibcode = citation_change.citing
     expected_target_id = citation_change.content
     expected_target_id_schema = "ascl"
     expected_target_url = "https://ascl.net/{}".format(expected_target_id)
     is_link_alive = True
     license_info = {
         'license_url': 'https://creativecommons.org/publicdomain/zero/1.0/'
     }
     parsed_metadata = {
         'link_alive': is_link_alive,
         "doctype": "software",
         'license_name': license_info.get('license_name', ""),
         'license_url': license_info.get('license_url', "")
     }
     expected_json_body = self._build_expected_json_body(
         expected_event_type, expected_original_relationship_name,
         expected_source_bibcode, expected_target_id,
         expected_target_id_schema, expected_target_url,
         parsed_metadata.get('doctype', ""),
         parsed_metadata.get('license_url', ""))
     event_data = webhook.citation_change_to_event_data(citation_change)
     emitted = webhook.emit_event(self.app.conf['ADS_WEBHOOK_URL'],
                                  self.app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                  event_data,
                                  timeout=30)
     self.assertFalse(
         emitted,
         "Agreed citation change was NOT assigned to an agreed event")
def task_emit_event(event_data, dump_prefix):
    """
    Emit event
    """
    emitted = False
    relationship = event_data.get("RelationshipType", {}).get("SubType", None)
    source_id = event_data.get("Source", {}).get("Identifier",
                                                 {}).get("ID", None)
    target_id = event_data.get("Target", {}).get("Identifier",
                                                 {}).get("ID", None)

    if not app.conf['TESTING_MODE']:
        prefix = os.path.join("emitted", relationship)
        emitted = webhook.emit_event(app.conf['ADS_WEBHOOK_URL'],
                                     app.conf['ADS_WEBHOOK_AUTH_TOKEN'],
                                     event_data)
    else:
        prefix = os.path.join("emulated", relationship)
        emitted = True
    if isinstance(dump_prefix, basestring):
        prefix = os.path.join(prefix, dump_prefix)
    webhook.dump_event(event_data, prefix=prefix)
    stored = db.store_event(app, event_data)

    if app.conf['TESTING_MODE'] and emitted:
        logger.debug(
            "Emulated emission of event due to 'testing mode' (relationship '%s', source '%s' and target '%s')",
            relationship, source_id, target_id)
    elif emitted:
        logger.debug(
            "Emitted event (relationship '%s', source '%s' and target '%s')",
            relationship, source_id, target_id)
    else:
        logger.debug(
            "Non-emitted event (relationship '%s', source '%s' and target '%s')",
            relationship, source_id, target_id)