def test_results(expected_items, descriptions, search_value):
    expected_items = [Prescription(description=description) for description in expected_items]
    items = [Prescription(description=description) for description in descriptions]

    search = Search(search_value, items)

    assert expected_items == search.results
def test_value_result_starts_with_when_one_character():
    expected_item = Prescription(description='A')
    expected_items = [expected_item]

    items = []
    items.append(expected_item)
    items.append(Prescription(description='bA'))

    search = Search('a', items)

    assert expected_items == search._value_results
def test_value_fuzzy_result():
    expected_item_first = Prescription(description='ABECD')
    expected_item_second = Prescription(description='ABICD')
    expected_items = [expected_item_first, expected_item_second]

    items = []
    items.append(expected_item_first)
    items.append(expected_item_second)
    items.append(Prescription(description='DEFG'))

    search = Search('abe', items)

    assert expected_items == search._value_fuzzy_results
def test_value_result_contains_when_multiple_characters():
    expected_item_first = Prescription(description='ABCD')
    expected_item_second = Prescription(description='BCDE')
    expected_items = [expected_item_first, expected_item_second]

    items = []
    items.append(expected_item_first)
    items.append(expected_item_second)
    items.append(Prescription(description='DEFG'))

    search = Search('bc', items)

    assert expected_items == search._value_results
def test_value_fuzzy_result_none_fuzzy():
    expected_items = []
    items = [Prescription(description='D')]

    search = Search('D', items)
    search.value_fuzzy = None

    assert expected_items == search._value_fuzzy_results
Exemple #6
0
 def _build_prescription(self, description, national_drug_code,
                         cost_per_unit, pricing_unit, is_over_the_counter,
                         is_brand, is_high_cost):
     return Prescription(description=description,
                         national_drug_code=national_drug_code,
                         cost_per_unit=cost_per_unit,
                         pricing_unit=pricing_unit,
                         is_over_the_counter=is_over_the_counter,
                         is_brand=is_brand,
                         is_high_cost=is_high_cost)
Exemple #7
0
def test_init_prescription_with_keyword_args():
    prescription = Prescription(description='apple',
                                national_drug_code=0,
                                cost_per_unit=0,
                                pricing_unit='',
                                is_over_the_counter=False,
                                is_brand=False,
                                is_high_cost=False)

    assert prescription
    assert 'APL' == prescription.fuzzy
Exemple #8
0
from app.meda_sync_search.models.prescription import Prescription
from app.meda_sync_search.services.prescription_loader import PrescriptionLoader

expected_prescriptions_data = [
    OrderedDict([('NDC Description', '12-HR DECONGEST 120 MG CAPLET'),
                 ('NDC', '113005452'), ('NADAC_Per_Unit', ' $0.34 '),
                 ('Effective_Date', '5/17/17'), ('Pricing_Unit', 'EA'),
                 ('OTC', 'Y'), ('Brand/Generic', 'G'),
                 ('As of Date', '6/7/17'), ('High Cost', 'Low')]),
]

expected_prescription = Prescription(
    description='12-HR DECONGEST 120 MG CAPLET',
    national_drug_code=113005452,
    cost_per_unit=0.34,
    pricing_unit='EA',
    is_over_the_counter=True,
    is_brand=False,
    is_high_cost=False)


def test_init_prescription_loader_service():
    expected_data_file_path = '/'
    prescription_loader = PrescriptionLoader(expected_data_file_path)

    assert prescription_loader
    assert expected_data_file_path == prescription_loader.data_file_path


@patch(
    'app.meda_sync_search.services.prescription_loader.PrescriptionLoader._read'
Exemple #9
0
    assert expected_prescriptions == prescriptions_data_transformer.transform()


prescriptions_data = [
    OrderedDict([('NDC Description', 'desc1'), ('NDC', '1'),
                 ('NADAC_Per_Unit', ' $0.34 '), ('Effective_Date', '5/17/17'),
                 ('Pricing_Unit', 'EA'), ('OTC', 'Y'), ('Brand/Generic', 'G'),
                 ('As of Date', '6/7/17'), ('High Cost', 'Low')]),
    OrderedDict([('NDC Description', 'desc2'), ('NDC', '2'),
                 ('NADAC_Per_Unit', '$1.34'), ('Effective_Date', '5/17/17'),
                 ('Pricing_Unit', 'ML'), ('OTC', 'N'), ('Brand/Generic', 'B'),
                 ('As of Date', '6/7/17'), ('High Cost', 'High')]),
]

expected_prescriptions = [
    Prescription(description='desc1',
                 national_drug_code=1,
                 cost_per_unit=.34,
                 pricing_unit='EA',
                 is_over_the_counter=True,
                 is_brand=False,
                 is_high_cost=False),
    Prescription(description='desc2',
                 national_drug_code=2,
                 cost_per_unit=1.34,
                 pricing_unit='ML',
                 is_over_the_counter=False,
                 is_brand=True,
                 is_high_cost=True)
]
Exemple #10
0
def test_hash():
    expected_hash = int(hashlib.sha1(expected_serialize_str).hexdigest(), 16)
    prescription = Prescription()
    assert expected_hash == prescription.__hash__()
Exemple #11
0
def test_repr():
    prescription = Prescription()
    assert expected_serialize_str == prescription.__repr__()
Exemple #12
0
def test_serialize():
    prescription = Prescription()
    assert expected_serialize_str == prescription.serialize()
Exemple #13
0
def test_init_prescription():
    prescription = Prescription()

    assert prescription