Browse Source
[MIG] base_location_geonames_import: Initial migration to 9.0
[MIG] base_location_geonames_import: Initial migration to 9.0
[IMP] base_location_geonames_import: Make tests more efficient [FIX] base_location_geonames_import: Don't alias Warning [IMP] base_location_geonames_import: Convert tests to Python + switch imported country Monaco country is very little and it allows to save some downloaded bytes plus making a test for entries deletion [IMP] base_location_geonames_import: Switch author [FIX] base_location_geonames_import: Fix test [FIX] base_location_geonames_import: Fix tests [MIG] Make modules uninstallable [MIG] Rename manifest files [FIX] base_location_geonames_import: Test logic changed For avoiding constant problems with this test, as Monaco data changes a lot, what we are testing now is the existence of the data, not the exact match of them.pull/643/head
Pedro M. Baeza
9 years ago
10 changed files with 120 additions and 245 deletions
-
22base_location_geonames_import/README.rst
-
23base_location_geonames_import/__init__.py
-
25base_location_geonames_import/__manifest__.py
-
48base_location_geonames_import/__openerp__.py
-
68base_location_geonames_import/i18n/base_location_geonames_import.pot
-
54base_location_geonames_import/test/import.yml
-
4base_location_geonames_import/tests/__init__.py
-
46base_location_geonames_import/tests/test_base_location_geonames_import.py
-
23base_location_geonames_import/wizard/__init__.py
-
52base_location_geonames_import/wizard/geonames_import.py
@ -1,23 +1,4 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Base Location Geonames Import module for OpenERP |
|||
# Copyright (C) 2014 Akretion (http://www.akretion.com) |
|||
# @author Alexis de Lattre <alexis.delattre@akretion.com> |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
# -*- coding: utf-8 -*- |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import wizard |
@ -0,0 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2014 Alexis de Lattre <alexis.delattre@akretion.com> |
|||
# © 2014 Lorenzo Battistini <lorenzo.battistini@agilebg.com> |
|||
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
{ |
|||
'name': 'Base Location Geonames Import', |
|||
'version': '9.0.1.0.1', |
|||
'category': 'Partner Management', |
|||
'license': 'AGPL-3', |
|||
'summary': 'Import better zip entries from Geonames', |
|||
'author': 'Akretion,' |
|||
'Agile Business Group,' |
|||
'Antiun Ingeniería S.L.,' |
|||
'Tecnativa,' |
|||
'Odoo Community Association (OCA)', |
|||
'website': 'http://www.akretion.com', |
|||
'depends': ['base_location'], |
|||
'external_dependencies': {'python': ['requests', 'unicodecsv']}, |
|||
'data': [ |
|||
'wizard/geonames_import_view.xml', |
|||
], |
|||
'installable': False, |
|||
} |
@ -1,48 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Base Location Geonames Import module for OpenERP |
|||
# Copyright (C) 2014 Akretion (http://www.akretion.com) |
|||
# @author Alexis de Lattre <alexis.delattre@akretion.com> |
|||
# Copyright (C) 2014 Agile Business Group (http://www.agilebg.com) |
|||
# @author Lorenzo Battistini <lorenzo.battistini@agilebg.com> |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
|
|||
{ |
|||
'name': 'Base Location Geonames Import', |
|||
'version': '8.0.0.3.0', |
|||
'category': 'Extra Tools', |
|||
'license': 'AGPL-3', |
|||
'summary': 'Import better zip entries from Geonames', |
|||
'author': 'Akretion,' |
|||
'Agile Business Group,' |
|||
'Antiun Ingeniería S.L.,' |
|||
'Serv. Tecnol. Avanzados - Pedro M. Baeza,' |
|||
'Odoo Community Association (OCA)', |
|||
'website': 'http://www.akretion.com', |
|||
'depends': ['base_location'], |
|||
'external_dependencies': {'python': ['requests', 'unicodecsv']}, |
|||
'data': [ |
|||
'wizard/geonames_import_view.xml', |
|||
], |
|||
'test': [ |
|||
'test/import.yml' |
|||
], |
|||
'installable': True, |
|||
'active': False, |
|||
} |
@ -1,68 +0,0 @@ |
|||
# Translation of OpenERP Server. |
|||
# This file contains the translation of the following modules: |
|||
# * base_location_geonames_import |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: OpenERP Server 7.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2014-04-11 20:55+0000\n" |
|||
"PO-Revision-Date: 2014-04-11 20:55+0000\n" |
|||
"Last-Translator: <>\n" |
|||
"Language-Team: \n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: \n" |
|||
|
|||
#. module: base_location_geonames_import |
|||
#: view:better.zip.geonames.import:0 |
|||
msgid "Cancel" |
|||
msgstr "" |
|||
|
|||
#. module: base_location_geonames_import |
|||
#: field:better.zip.geonames.import,country_id:0 |
|||
msgid "Country" |
|||
msgstr "" |
|||
|
|||
#. module: base_location_geonames_import |
|||
#: code:addons/base_location_geonames_import/wizard/geonames_import.py:66 |
|||
#: code:addons/base_location_geonames_import/wizard/geonames_import.py:90 |
|||
#, python-format |
|||
msgid "Error:" |
|||
msgstr "" |
|||
|
|||
#. module: base_location_geonames_import |
|||
#: view:better.zip.geonames.import:0 |
|||
msgid "For the country selected above, this wizard will download the latest version of the list of cities from geonames.org, create new location entries if not found already in the system, and DELETE MISSING ENTRIES from new file." |
|||
msgstr "" |
|||
|
|||
#. module: base_location_geonames_import |
|||
#: code:addons/base_location_geonames_import/wizard/geonames_import.py:91 |
|||
#, python-format |
|||
msgid "Got an error %d when trying to download the file %s." |
|||
msgstr "" |
|||
|
|||
#. module: base_location_geonames_import |
|||
#: view:better.zip.geonames.import:0 |
|||
msgid "Import" |
|||
msgstr "" |
|||
|
|||
#. module: base_location_geonames_import |
|||
#: model:ir.model,name:base_location_geonames_import.model_better_zip_geonames_import |
|||
msgid "Import Better Zip from Geonames" |
|||
msgstr "" |
|||
|
|||
#. module: base_location_geonames_import |
|||
#: view:better.zip.geonames.import:0 |
|||
#: model:ir.actions.act_window,name:base_location_geonames_import.better_zip_geonames_import_action |
|||
#: model:ir.ui.menu,name:base_location_geonames_import.better_zip_geonames_import_menu |
|||
msgid "Import from Geonames" |
|||
msgstr "" |
|||
|
|||
#. module: base_location_geonames_import |
|||
#: code:addons/base_location_geonames_import/wizard/geonames_import.py:67 |
|||
#, python-format |
|||
msgid "The country code inside the file (%s) doesn't correspond to the selected country (%s)." |
|||
msgstr "" |
|||
|
@ -1,54 +0,0 @@ |
|||
- |
|||
I create the wizard |
|||
- |
|||
!record {model: better.zip.geonames.import, id: import_wizard_1, view: better_zip_geonames_import_form}: |
|||
country_id: base.it |
|||
- |
|||
I run the import |
|||
- |
|||
!python {model: better.zip.geonames.import}: | |
|||
self.run_import(cr, uid, [ref('import_wizard_1')], context=context) |
|||
- |
|||
I check the data |
|||
- |
|||
!python {model: res.better.zip}: | |
|||
state_obj = self.pool['res.country.state'] |
|||
state_ids = state_obj.search(cr, uid, [ |
|||
('code', '=', 'LG'), |
|||
('country_id', '=', ref('base.it')), |
|||
], context=context) |
|||
assert len(state_ids) == 1, "There must be 1 LG" |
|||
zip_ids = self.search(cr, uid, [ |
|||
('name', '=', '16017'), |
|||
('city', '=', 'Isola Del Cantone'), |
|||
('state_id', '=', state_ids[0]), |
|||
('country_id', '=', ref('base.it')) |
|||
], context=context) |
|||
assert len(zip_ids) == 1, "There must be 1 'Isola Del Cantone'" |
|||
- |
|||
I create the wizard again |
|||
- |
|||
!record {model: better.zip.geonames.import, id: import_wizard_2, view: better_zip_geonames_import_form}: |
|||
country_id: base.it |
|||
- |
|||
I run the import again |
|||
- |
|||
!python {model: better.zip.geonames.import}: | |
|||
self.run_import(cr, uid, [ref('import_wizard_2')], context=context) |
|||
- |
|||
I check the data |
|||
- |
|||
!python {model: res.better.zip}: | |
|||
state_obj = self.pool['res.country.state'] |
|||
state_ids = state_obj.search(cr, uid, [ |
|||
('code', '=', 'LG'), |
|||
('country_id', '=', ref('base.it')), |
|||
], context=context) |
|||
assert len(state_ids) == 1, "There must be 1 LG" |
|||
zip_ids = self.search(cr, uid, [ |
|||
('name', '=', '16017'), |
|||
('city', '=', 'Isola Del Cantone'), |
|||
('state_id', '=', state_ids[0]), |
|||
('country_id', '=', ref('base.it')) |
|||
], context=context) |
|||
assert len(zip_ids) == 1, "There must be 1 'Isola Del Cantone'" |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import test_base_location_geonames_import |
@ -0,0 +1,46 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from openerp.tests import common |
|||
|
|||
|
|||
class TestBaseLocationGeonamesImport(common.TransactionCase): |
|||
def setUp(self): |
|||
super(TestBaseLocationGeonamesImport, self).setUp() |
|||
self.country = self.env.ref('base.mc') |
|||
self.wizard = self.env['better.zip.geonames.import'].create({ |
|||
'country_id': self.country.id, |
|||
}) |
|||
|
|||
def test_import_country(self): |
|||
max_import = 10 |
|||
self.wizard.with_context(max_import=max_import).run_import() |
|||
# Look if there are imported states for the country |
|||
state_count = self.env['res.country.state'].search_count([ |
|||
('country_id', '=', self.country.id) |
|||
]) |
|||
self.assertTrue(state_count) |
|||
# Look if the are imported zips |
|||
zip_count = self.env['res.better.zip'].search_count([ |
|||
('country_id', '=', self.country.id) |
|||
]) |
|||
self.assertEqual(zip_count, max_import) |
|||
# Reimport again to see that there's no duplicates |
|||
self.wizard.with_context(max_import=max_import).run_import() |
|||
state_count2 = self.env['res.country.state'].search_count([ |
|||
('country_id', '=', self.country.id) |
|||
]) |
|||
self.assertEqual(state_count, state_count2) |
|||
zip_count = self.env['res.better.zip'].search_count([ |
|||
('country_id', '=', self.country.id) |
|||
]) |
|||
self.assertEqual(zip_count, max_import) |
|||
|
|||
def test_delete_old_entries(self): |
|||
zip_entry = self.env['res.better.zip'].create({ |
|||
'city': 'Test city', |
|||
'country_id': self.country.id, |
|||
}) |
|||
self.wizard.run_import() |
|||
self.assertFalse(zip_entry.exists()) |
@ -1,23 +1,4 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Base Location Geonames Import module for OpenERP |
|||
# Copyright (C) 2014 Akretion (http://www.akretion.com) |
|||
# @author Alexis de Lattre <alexis.delattre@akretion.com> |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
# -*- coding: utf-8 -*- |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import geonames_import |
Write
Preview
Loading…
Cancel
Save
Reference in new issue