def test_amend_package(self):
        directory = os.path.dirname(os.path.abspath(__file__))
        moers_file = open(directory + '/moers.json')
        package = json.loads(moers_file.read())

        harvester = MoersCKANHarvester()
        harvester.amend_package(package)

        self.assertIsNotNone(package['id'])
        self.assertTrue(package['title'].endswith(' Moers'))

        self.assertNotIn(u'ü', package['name'])
        self.assertNotIn(u'ö', package['name'])
        self.assertNotIn(u'ä', package['name'])
        self.assertNotIn(u'ß', package['name'])

        self.assertEqual(package['author'], 'Stadt Moers')
        self.assertEqual(package['author_email'], '*****@*****.**')
        self.assertEqual(package['maintainer'], 'Ilona Bajorat')
        self.assertEqual(package['maintainer_email'], '*****@*****.**')

        self.assertEqual(package['license_id'], 'dl-de-by-1.0')
        self.assertEqual(package['extras']['metadata_original_portal'],
                         'http://www.offenedaten.moers.de/')

        self.assertEqual(package['extras']['spatial-text'],
                         '05 1 70 024 Moers')

        self.assertEqual(package['resources'][0]['format'], 'json')
    def test_title_amendment(self):

        publisher = {'role': 'veroeffentlichende_stelle',
                     'name': 'name',
                     'email': 'email'}

        maintainer = {'role': 'ansprechpartner',
                      'name': 'name',
                      'email': 'email'}

        valid_package = {'name': 'name',
                         'title': 'Adressen in Moers',
                         'resources': [],
                         'tags': [],
                         'extras': {'contacts': [publisher, maintainer],
                                    'terms_of_use': {'license_id': 'id'}}}

        invalid_package = {'name': 'name',
                          'title': 'Straßennamen',
                          'resources': [],
                          'tags': [],
                          'extras': {'contacts': [publisher, maintainer],
                                     'terms_of_use': {'license_id': 'id'}}}

        harvester = MoersCKANHarvester()
        harvester.amend_package(valid_package)
        harvester.amend_package(invalid_package)
        self.assertEqual(valid_package['title'], 'Adressen in Moers')
        self.assertEqual(invalid_package['title'], 'Straßennamen Moers')