From 96e459c938eadf83a07e953cf58fef1a450d9ec8 Mon Sep 17 00:00:00 2001 From: Lunga Baliwe Date: Sun, 25 Aug 2024 08:56:37 +0200 Subject: [PATCH 1/4] Fixed - ImportError: No module named instrument format_keyword import error --- .../instruments/instruments/agilent/chemstation/chemstation.py | 2 +- src/senaite/instruments/instruments/agilent/masshunter/aorc.py | 2 +- .../instruments/instruments/agilent/masshunter/qualitative.py | 2 +- .../instruments/instruments/agilent/masshunter/quantitative.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py b/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py index b22afaa..2b3cb4b 100644 --- a/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py +++ b/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py @@ -8,7 +8,7 @@ from senaite.core.exportimport.instruments import IInstrumentAutoImportInterface from senaite.core.exportimport.instruments import IInstrumentExportInterface from senaite.core.exportimport.instruments import IInstrumentImportInterface -from senaite.core.exportimport.instruments.instrument import format_keyword +from senaite.core.exportimport.instruments.utils import format_keyword from senaite.core.exportimport.instruments.resultsimport import AnalysisResultsImporter from bika.lims.utils import t from cStringIO import StringIO diff --git a/src/senaite/instruments/instruments/agilent/masshunter/aorc.py b/src/senaite/instruments/instruments/agilent/masshunter/aorc.py index dc4d73d..534c735 100644 --- a/src/senaite/instruments/instruments/agilent/masshunter/aorc.py +++ b/src/senaite/instruments/instruments/agilent/masshunter/aorc.py @@ -6,7 +6,7 @@ from bika.lims import bikaMessageFactory as _ from senaite.core.exportimport.instruments import IInstrumentAutoImportInterface from senaite.core.exportimport.instruments import IInstrumentImportInterface -from senaite.core.exportimport.instruments.instrument import format_keyword +from senaite.core.exportimport.instruments.utils import format_keyword from senaite.core.exportimport.instruments.resultsimport import AnalysisResultsImporter from bika.lims.utils import t from DateTime import DateTime diff --git a/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py b/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py index 9512cd9..ca71e8d 100644 --- a/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py +++ b/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py @@ -8,7 +8,7 @@ from senaite.core.exportimport.instruments import IInstrumentAutoImportInterface from senaite.core.exportimport.instruments import IInstrumentExportInterface from senaite.core.exportimport.instruments import IInstrumentImportInterface -from senaite.core.exportimport.instruments.instrument import format_keyword +from senaite.core.exportimport.instruments.utils import format_keyword from senaite.core.exportimport.instruments.resultsimport import AnalysisResultsImporter from senaite.core.exportimport.instruments.resultsimport import InstrumentCSVResultsFileParser from bika.lims.utils import t diff --git a/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py b/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py index c4bb7a2..1051c9a 100644 --- a/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py +++ b/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py @@ -8,7 +8,7 @@ from senaite.core.exportimport.instruments import IInstrumentAutoImportInterface from senaite.core.exportimport.instruments import IInstrumentExportInterface from senaite.core.exportimport.instruments import IInstrumentImportInterface -from senaite.core.exportimport.instruments.instrument import format_keyword +from senaite.core.exportimport.instruments.utils import format_keyword from senaite.core.exportimport.instruments.resultsimport import AnalysisResultsImporter from senaite.core.exportimport.instruments.resultsimport import InstrumentCSVResultsFileParser from bika.lims.utils import t From 2677211b6a48f273b2dd4133ccfce9e8f70c3d94 Mon Sep 17 00:00:00 2001 From: Lunga Baliwe Date: Sun, 25 Aug 2024 10:26:53 +0200 Subject: [PATCH 2/4] Fixed some of the failing test --- src/senaite/instruments/docs/INSTRUMENTS.rst | 7 ++++--- .../agilent/chemstation/chemstation.py | 2 +- .../instruments/agilent/masshunter/aorc.py | 2 +- .../agilent/masshunter/qualitative.py | 2 +- .../agilent/masshunter/quantitative.py | 2 +- .../instruments/bruker/s8tiger/s8tiger.py | 2 +- .../perkinelmer/nexion350x/nexion350x.py | 2 +- .../perkinelmer/winlab32/winlab32.py | 2 +- src/senaite/instruments/tests/base.py | 19 ++++--------------- 9 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/senaite/instruments/docs/INSTRUMENTS.rst b/src/senaite/instruments/docs/INSTRUMENTS.rst index 04911f4..0881eb5 100644 --- a/src/senaite/instruments/docs/INSTRUMENTS.rst +++ b/src/senaite/instruments/docs/INSTRUMENTS.rst @@ -41,10 +41,11 @@ Variables:: >>> portal = self.portal >>> request = self.request >>> bika_setup = portal.bika_setup + >>> setup = portal.setup >>> bika_instruments = bika_setup.bika_instruments >>> bika_sampletypes = bika_setup.bika_sampletypes - >>> bika_samplepoints = bika_setup.bika_samplepoints - >>> bika_analysiscategories = bika_setup.bika_analysiscategories + >>> bika_samplepoints = setup.samplepoints + >>> bika_analysiscategories = setup.analysiscategories >>> bika_analysisservices = bika_setup.bika_analysisservices >>> bika_calculations = bika_setup.bika_calculations >>> bika_methods = portal.methods @@ -116,7 +117,7 @@ This service matches the service specified in the file from which the import wil >>> analysiscategory = api.create(bika_analysiscategories, "AnalysisCategory", title="Water") >>> analysiscategory - + >>> analysisservice1 = api.create(bika_analysisservices, ... "AnalysisService", ... title="HIV06ml", diff --git a/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py b/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py index 2b3cb4b..adfc1fb 100644 --- a/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py +++ b/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py @@ -234,7 +234,7 @@ def Import(self, context, request): importer = AnalysisResultsImporter( parser=parser, context=context, - allowed_ar_states=status, + allowed_sample_states=status, allowed_analysis_states=None, override=over, instrument_uid=instrument) diff --git a/src/senaite/instruments/instruments/agilent/masshunter/aorc.py b/src/senaite/instruments/instruments/agilent/masshunter/aorc.py index 534c735..abec757 100644 --- a/src/senaite/instruments/instruments/agilent/masshunter/aorc.py +++ b/src/senaite/instruments/instruments/agilent/masshunter/aorc.py @@ -168,7 +168,7 @@ def Import(self, context, request): importer = AnalysisResultsImporter( parser=parser, context=context, - allowed_ar_states=status, + allowed_sample_states=status, allowed_analysis_states=None, override=over, instrument_uid=instrument) diff --git a/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py b/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py index ca71e8d..60d937c 100644 --- a/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py +++ b/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py @@ -167,7 +167,7 @@ def Import(self, context, request): importer = QualitativeImporter( parser=parser, context=context, - allowed_ar_states=status, + allowed_sample_states=status, allowed_analysis_states=None, override=over, instrument_uid=instrument) diff --git a/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py b/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py index 1051c9a..1ce50f3 100644 --- a/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py +++ b/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py @@ -188,7 +188,7 @@ def Import(self, context, request): importer = QuantitativeImporter( parser=parser, context=context, - allowed_ar_states=status, + allowed_sample_states=status, allowed_analysis_states=None, override=over, instrument_uid=instrument) diff --git a/src/senaite/instruments/instruments/bruker/s8tiger/s8tiger.py b/src/senaite/instruments/instruments/bruker/s8tiger/s8tiger.py index faa402d..77710c2 100644 --- a/src/senaite/instruments/instruments/bruker/s8tiger/s8tiger.py +++ b/src/senaite/instruments/instruments/bruker/s8tiger/s8tiger.py @@ -266,7 +266,7 @@ def Import(context, request): importer = AnalysisResultsImporter( parser=parser, context=context, - allowed_ar_states=status, + allowed_sample_states=status, allowed_analysis_states=None, override=over, instrument_uid=instrument) diff --git a/src/senaite/instruments/instruments/perkinelmer/nexion350x/nexion350x.py b/src/senaite/instruments/instruments/perkinelmer/nexion350x/nexion350x.py index 52d17e7..061e571 100644 --- a/src/senaite/instruments/instruments/perkinelmer/nexion350x/nexion350x.py +++ b/src/senaite/instruments/instruments/perkinelmer/nexion350x/nexion350x.py @@ -210,7 +210,7 @@ def Import(context, request): importer = AnalysisResultsImporter( parser=parser, context=context, - allowed_ar_states=status, + allowed_sample_states=status, allowed_analysis_states=None, override=over, instrument_uid=instrument) diff --git a/src/senaite/instruments/instruments/perkinelmer/winlab32/winlab32.py b/src/senaite/instruments/instruments/perkinelmer/winlab32/winlab32.py index 89b171d..444d143 100644 --- a/src/senaite/instruments/instruments/perkinelmer/winlab32/winlab32.py +++ b/src/senaite/instruments/instruments/perkinelmer/winlab32/winlab32.py @@ -196,7 +196,7 @@ def Import(context, request): importer = AnalysisResultsImporter( parser=parser, context=context, - allowed_ar_states=status, + allowed_sample_states=status, allowed_analysis_states=None, override=over, instrument_uid=instrument) diff --git a/src/senaite/instruments/tests/base.py b/src/senaite/instruments/tests/base.py index 9e7606e..f284109 100644 --- a/src/senaite/instruments/tests/base.py +++ b/src/senaite/instruments/tests/base.py @@ -4,7 +4,6 @@ # # Copyright 2018 by it's authors. -from datetime import datetime import unittest2 as unittest from plone.app.testing import FunctionalTesting @@ -21,8 +20,6 @@ from Products.Archetypes.event import ObjectInitializedEvent from Products.CMFPlone.utils import _createObjectByType -from bika.lims import SETUP_CATALOG -from bika.lims import api from bika.lims.idserver import renameAfterCreation from bika.lims.utils import tmpID from bika.lims.utils.analysisrequest import create_analysisrequest @@ -138,29 +135,23 @@ def add_contact(self, folder, **kwargs): return obj def add_manufacturer(self, **kwargs): - folder = self.portal.bika_setup.bika_manufacturers + folder = self.portal.setup.manufacturers obj = _createObjectByType('Manufacturer', folder, tmpID()) obj.edit(**kwargs) - obj.unmarkCreationFlag() - renameAfterCreation(obj) notify(ObjectInitializedEvent(obj)) return obj def add_supplier(self, **kwargs): - folder = self.portal.bika_setup.bika_suppliers + folder = self.portal.setup.suppliers obj = _createObjectByType('Supplier', folder, tmpID()) obj.edit(**kwargs) - obj.unmarkCreationFlag() - renameAfterCreation(obj) notify(ObjectInitializedEvent(obj)) return obj def add_instrumenttype(self, **kwargs): - folder = self.portal.bika_setup.bika_instrumenttypes + folder = self.portal.setup.instrumenttypes obj = _createObjectByType('InstrumentType', folder, tmpID()) obj.edit(**kwargs) - obj.unmarkCreationFlag() - renameAfterCreation(obj) notify(ObjectInitializedEvent(obj)) return obj @@ -174,11 +165,9 @@ def add_instrument(self, **kwargs): return obj def add_analysiscategory(self, **kwargs): - folder = self.portal.bika_setup.bika_analysiscategories + folder = self.portal.setup.analysiscategories obj = _createObjectByType('AnalysisCategory', folder, tmpID()) obj.edit(**kwargs) - obj.unmarkCreationFlag() - renameAfterCreation(obj) notify(ObjectInitializedEvent(obj)) return obj From 2e15c2876ab26ddae59ad1d04f9050b12baa88bf Mon Sep 17 00:00:00 2001 From: Lunga Baliwe Date: Sun, 25 Aug 2024 11:17:27 +0200 Subject: [PATCH 3/4] Tests pass --- .../instruments/instruments/bruker/s8tiger/s8tiger.py | 10 ++++++---- .../instruments/perkinelmer/nexion350x/nexion350x.py | 2 +- .../instruments/perkinelmer/winlab32/winlab32.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/senaite/instruments/instruments/bruker/s8tiger/s8tiger.py b/src/senaite/instruments/instruments/bruker/s8tiger/s8tiger.py index 77710c2..ee2def0 100644 --- a/src/senaite/instruments/instruments/bruker/s8tiger/s8tiger.py +++ b/src/senaite/instruments/instruments/bruker/s8tiger/s8tiger.py @@ -137,13 +137,15 @@ def parse(self): reader = csv.DictReader(lines) for row in reader: self.parse_row(ar, reader.line_num, row) - return 0 + return True def parse_row(self, ar, row_nr, row): + # commented out the the next 4 lines out becuase reading is not in + # field_interim_map in 47 where it is defined # convert row to use interim field names - if 'reading' not in field_interim_map.values(): - self.err("Missing 'reading' interim field.") - return -1 + # if 'reading' not in field_interim_map.values(): + # self.err("Missing 'reading' interim field.") + # return -1 parsed = {field_interim_map.get(k, ''): v for k, v in row.items()} formula = parsed.get('formula') diff --git a/src/senaite/instruments/instruments/perkinelmer/nexion350x/nexion350x.py b/src/senaite/instruments/instruments/perkinelmer/nexion350x/nexion350x.py index 061e571..f1558ea 100644 --- a/src/senaite/instruments/instruments/perkinelmer/nexion350x/nexion350x.py +++ b/src/senaite/instruments/instruments/perkinelmer/nexion350x/nexion350x.py @@ -105,7 +105,7 @@ def parse(self): reader = csv.DictReader(lines) for row in reader: self.parse_row(reader.line_num, row) - return 0 + return True def parse_row(self, row_nr, row): if row['Sample Id'].lower().strip() in ( diff --git a/src/senaite/instruments/instruments/perkinelmer/winlab32/winlab32.py b/src/senaite/instruments/instruments/perkinelmer/winlab32/winlab32.py index 444d143..764ba99 100644 --- a/src/senaite/instruments/instruments/perkinelmer/winlab32/winlab32.py +++ b/src/senaite/instruments/instruments/perkinelmer/winlab32/winlab32.py @@ -96,7 +96,7 @@ def parse(self): reader = csv.DictReader(lines) for row in reader: self.parse_row(reader.line_num, row) - return 0 + return True def parse_row(self, row_nr, row): # convert row to use interim field names From a013d1951ccfc79269774addf1256d3efc3a2d3b Mon Sep 17 00:00:00 2001 From: Lunga Baliwe Date: Wed, 11 Sep 2024 08:11:23 +0200 Subject: [PATCH 4/4] Update CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 91fe8d9..bda2020 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changelog 1.0.0 (unreleased) ------------------ +- #10 Fix failing tests - #8 Fix nexion350x Instrument by not lowering keywords - #7 Fix Winlab Instrument by not lowering keywords - First version of `senaite.instruments`