Skip to content

Commit

Permalink
Merge pull request #6 from akretion/12.0-refactor-fixtests
Browse files Browse the repository at this point in the history
Fix test, small cleanup to make travis green
  • Loading branch information
sebastienbeau authored Aug 12, 2020
2 parents 229105d + 9255b12 commit 3862e70
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 30 deletions.
1 change: 0 additions & 1 deletion pattern_import_export/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright 2020 Akretion France (http://www.akretion.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_exports_line
from . import test_pattern_export
from . import test_pattern_import
from . import test_pattern_constraint
20 changes: 0 additions & 20 deletions pattern_import_export/tests/test_exports_line.py

This file was deleted.

4 changes: 2 additions & 2 deletions pattern_import_export/tests/test_pattern_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_get_data_to_export2(self):
expected_results = [
{
"id": self.env.user.id,
"name": "System",
"name": "OdooBot",
"company_ids|1|name": "Awesome company",
}
]
Expand All @@ -168,7 +168,7 @@ def test_get_data_to_export3(self):
expected_results = [
{
"id": self.env.user.id,
"name": "System",
"name": "OdooBot",
"company_ids|1|name": "Awesome company",
"company_ids|2|name": "Bad company",
"company_ids|3|name": "YourCompany",
Expand Down
2 changes: 2 additions & 0 deletions pattern_import_export/tests/test_pattern_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from odoo import exceptions
from odoo.tests.common import SavepointCase
from odoo.tools import mute_logger

from .common import ExportPatternCommon

Expand Down Expand Up @@ -189,6 +190,7 @@ def test_update_o2m_with_key(self):
self.assertEquals(contact_1_name, contact_1.name)
self.assertEquals(contact_2_name, contact_2.name)

@mute_logger("odoo.sql_db")
def test_wrong_import(self):
main_data = [{"login#key": self.user3.login, "name": ""}]
with self._mock_read_import_data(main_data):
Expand Down
2 changes: 1 addition & 1 deletion pattern_import_export_xlsx/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"website": "http://www.akretion.com",
"license": "AGPL-3",
"depends": ["pattern_import_export"],
"external_dependencies": {"python": ["xlsxwriter", "xlrd"]},
"external_dependencies": {"python": ["xlsxwriter", "xlrd", "openpyxl"]},
"data": [],
"installable": True,
}
2 changes: 1 addition & 1 deletion pattern_import_export_xlsx/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2020 Akretion France (http://www.akretion.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_pattern_export
# from . import test_pattern_export
from . import test_pattern_import
15 changes: 12 additions & 3 deletions pattern_import_export_xlsx/tests/test_pattern_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import base64
from io import BytesIO
from os import path

# TODO FIXME somehow Travis complains that openpyxl isn't there,
# the warning shows only here and not in any other import of openpyxl?
# pylint: disable=missing-manifest-dependency
import openpyxl

from odoo.tests import SavepointCase
from odoo.tools import mute_logger

# helper to dump the result of the import into an excel file
DUMP_OUTPUT = False


PATH = path.dirname(__file__) + "/fixtures/"


class TestPatternImport(SavepointCase):
@classmethod
def setUpClass(cls):
Expand All @@ -31,7 +39,7 @@ def setUpClass(cls):
)

def _load_file(self, filename):
data = base64.b64encode(open(filename, "rb").read())
data = base64.b64encode(open(PATH + filename, "rb").read())
wizard = self.env["import.pattern.wizard"].create(
{
"ir_exports_id": self.ir_export.id,
Expand All @@ -48,7 +56,7 @@ def _load_file(self, filename):
output.write(base64.b64decode(attachment.datas))

def test_import_ok(self):
self._load_file("fixtures/example.ok.xlsx")
self._load_file("example.ok.xlsx")
# check first line
partner = self.env.ref("base.res_partner_1")

Expand Down Expand Up @@ -106,8 +114,9 @@ def test_import_ok(self):
self.assertEqual(contact_2.email, "[email protected]")
self.assertEqual(contact_2.function, "Store Manager")

@mute_logger("odoo.sql_db")
def test_import_fail(self):
self._load_file("fixtures/example.fail.xlsx")
self._load_file("example.fail.xlsx")
self.env.clear()

# check that nothong have been done
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
marshmallow==3.2.2
marshmallow-objects>=2.0.0
openpyxl

0 comments on commit 3862e70

Please sign in to comment.