aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-08-19 11:18:56 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-08-19 11:18:56 +0200
commit0cfdf4f12ef7b707eaa7031fd86a48fc87c570b4 (patch)
tree09afbb3ba0587952b3c53374b8c19852d701cfbc /src
parent4127fcc6d2266c26afc037a5d02d64b7f86df163 (diff)
downloadee-python-0cfdf4f12ef7b707eaa7031fd86a48fc87c570b4.tar.gz
ee-python-0cfdf4f12ef7b707eaa7031fd86a48fc87c570b4.tar.bz2
ee-python-0cfdf4f12ef7b707eaa7031fd86a48fc87c570b4.tar.xz
ee-python-0cfdf4f12ef7b707eaa7031fd86a48fc87c570b4.zip
digikey-search-parts: assert that the part we got was actually the one
we searched for.
Diffstat (limited to 'src')
-rw-r--r--src/ee/digikey/search_parts.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ee/digikey/search_parts.py b/src/ee/digikey/search_parts.py
index 144b254..eace4e3 100644
--- a/src/ee/digikey/search_parts.py
+++ b/src/ee/digikey/search_parts.py
@@ -2,6 +2,7 @@ import functools
from pathlib import Path
from typing import List, MutableSet, Mapping
+from ee import EeException
from ee.db import ObjDb
from ee.digikey import Digikey, DigikeyParser, DigikeyClient, SearchResponseTypes, DigikeyProduct, DigikeyStore
from ee.part import PartDb, load_db, save_db, Part
@@ -92,6 +93,13 @@ class QueryEngine(object):
result = "exception"
elif response.response_type == SearchResponseTypes.SINGLE:
out_part = resolved(self.store.url, response.products[0])
+
+ out_pn = out_part.get_exactly_one_spn() if is_spn else out_part.get_exactly_one_mpn()
+ out_pn = out_pn.valueProp
+ if out_pn != pn:
+ raise EeException("Internal error: returned PN/SPN didn't match expected parts: "
+ "query: {} vs returned: {}".format(pn, out_pn))
+
result = "found"
elif response.response_type == SearchResponseTypes.MANY:
# TODO: order by spn/mpn so the output is consistent between runs.