Beispiel #1
0
    def test_contactname_format_organisation(self, magic_mock):
        self.item['event_contact_info'] = [
            '5b7a8228f7ab23b336d7f84d',
            '7ab23b336d7f84d5b7a8228f',
        ]

        formatter = NTBEventFormatter()
        output = formatter.format(self.item, {})[0]
        root = lxml.etree.fromstring(output['encoded_item'])
        contactname = root.find('contactname')

        self.assertEqual(contactname.text, 'John Smith, NASA')
Beispiel #2
0
    def test_contactphone_not_included(self, magic_mock):
        self.item['event_contact_info'] = [
            '5b7a8228f7ab23b336d7f84d',
            '7ab23b336d7f84d5b7a8228f',
        ]

        formatter = NTBEventFormatter()
        output = formatter.format(self.item, {})[0]
        root = lxml.etree.fromstring(output['encoded_item'])
        contactphone = root.find('contactphone')
        contactphone_count = root.xpath('count(contactphone)')

        self.assertIsNone(contactphone)
        self.assertEqual(contactphone_count, 0)
Beispiel #3
0
    def test_location(self):
        formatter = NTBEventFormatter()

        # full address data
        output = formatter.format(self.item, {})[0]
        root = lxml.etree.fromstring(output['encoded_item'])
        location = root.find('location')
        self.assertEqual(
            location.text,
            'Prague, 1092/10 Salvatorska street, Old Town, Prague, 11000, Czechia'
        )

        # partly address data
        del self.item['location'][0]['address']['line']
        output = formatter.format(self.item, {})[0]
        root = lxml.etree.fromstring(output['encoded_item'])
        location = root.find('location')
        self.assertEqual(location.text,
                         'Prague, Old Town, Prague, 11000, Czechia')

        # no address data
        del self.item['location'][0]['address']
        output = formatter.format(self.item, {})[0]
        root = lxml.etree.fromstring(output['encoded_item'])
        location = root.find('location')
        self.assertEqual(location.text, 'Prague')

        # empty location name and no address data
        del self.item['location'][0]['name']
        output = formatter.format(self.item, {})[0]
        root = lxml.etree.fromstring(output['encoded_item'])
        location = root.find('location')
        self.assertIsNone(location.text)
Beispiel #4
0
 def test_ntb_id_ingested(self):
     formatter = NTBEventFormatter()
     item = self.item_ingested.copy()
     output = formatter.format(item, {})[0]
     root = lxml.etree.fromstring(output['encoded_item'])
     self.assertEqual('NBRP123456_123456_na_00', root.find('ntbId').text)
Beispiel #5
0
 def test_ntbid_duplicated(self):
     formatter = NTBEventFormatter()
     item = self.item_duplicated.copy()
     output = formatter.format(item, {})[0]
     root = lxml.etree.fromstring(output['encoded_item'])
     self.assertEqual('NBRP161031_093725_hh_00', root.find('ntbId').text)