-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes based on feedback, added tests
- Loading branch information
Showing
3 changed files
with
193 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1487,3 +1487,137 @@ def test_update_perk_fulfillment_state(self): | |
) | ||
obs = cur.fetchone() | ||
self.assertFalse(obs[0]) | ||
|
||
def test_get_barcodes_filter_kit_ids_success(self): | ||
with Transaction() as t: | ||
setup_sql = """ | ||
INSERT INTO barcodes.kit (kit_id, box_id) | ||
VALUES ('test1', '0001e15f-4170-4b28-b111-191cd567c347'); | ||
INSERT INTO barcodes.barcode (barcode, kit_id) | ||
VALUES ('00001234', 'test1'); | ||
""" | ||
with t.cursor() as cur: | ||
cur.execute(setup_sql) | ||
|
||
admin_repo = AdminRepo(t) | ||
|
||
barcodes = admin_repo.get_barcodes_filter(kit_ids=['test1']) | ||
self.assertEqual(barcodes, ['00001234']) | ||
|
||
def test_get_barcodes_filter_kit_ids_failure(self): | ||
with Transaction() as t: | ||
admin_repo = AdminRepo(t) | ||
barcodes = admin_repo.get_barcodes_filter(kit_ids=['notarealkit']) | ||
self.assertEqual(barcodes, []) | ||
|
||
def test_get_barcodes_filter_emails_success(self): | ||
with Transaction() as t: | ||
setup_sql = """ | ||
INSERT INTO ag.source (id, account_id, | ||
source_type, source_name) | ||
VALUES ('0003ddfd-4949-4105-90a9-1b1530af5352', %s, | ||
'Human', 'Test Source'); | ||
INSERT INTO barcodes.kit (kit_id, box_id) | ||
VALUES ('test1', '0001e15f-4170-4b28-b111-191cd567c347'); | ||
INSERT INTO barcodes.barcode (barcode, kit_id) | ||
VALUES ('00001234', 'test1'); | ||
INSERT INTO ag.ag_kit_barcodes (barcode, source_id) | ||
VALUES ('00001234', '0003ddfd-4949-4105-90a9-1b1530af5352'); | ||
""" | ||
with t.cursor() as cur: | ||
cur.execute(setup_sql, (STANDARD_ACCT_ID,)) | ||
|
||
admin_repo = AdminRepo(t) | ||
|
||
barcodes = admin_repo.get_barcodes_filter(emails=['[email protected]']) | ||
self.assertEqual(barcodes, ['00001234']) | ||
|
||
def test_get_barcodes_filter_emails_failure(self): | ||
with Transaction() as t: | ||
admin_repo = AdminRepo(t) | ||
barcodes = admin_repo.get_barcodes_filter( | ||
emails=['[email protected]']) | ||
self.assertEqual(barcodes, []) | ||
|
||
def test_get_barcodes_filter_outbound_tracking_success(self): | ||
with Transaction() as t: | ||
setup_sql = """ | ||
INSERT INTO barcodes.kit (kit_id, box_id, | ||
outbound_fedex_tracking) | ||
VALUES ('test1', '0001e15f-4170-4b28-b111-191cd567c347', | ||
'12345'); | ||
INSERT INTO barcodes.barcode (barcode, kit_id) | ||
VALUES ('00001234', 'test1'); | ||
""" | ||
with t.cursor() as cur: | ||
cur.execute(setup_sql) | ||
|
||
admin_repo = AdminRepo(t) | ||
|
||
barcodes = \ | ||
admin_repo.get_barcodes_filter( | ||
outbound_tracking_numbers=['12345']) | ||
self.assertEqual(barcodes, ['00001234']) | ||
|
||
def test_get_barcodes_filter_outbound_tracking_failure(self): | ||
with Transaction() as t: | ||
admin_repo = AdminRepo(t) | ||
barcodes = admin_repo.get_barcodes_filter( | ||
outbound_tracking_numbers=['99999']) | ||
self.assertEqual(barcodes, []) | ||
|
||
def test_get_barcodes_filter_inbound_tracking_success(self): | ||
with Transaction() as t: | ||
setup_sql = """ | ||
INSERT INTO barcodes.kit (kit_id, box_id, | ||
inbound_fedex_tracking) | ||
VALUES ('test1', '0001e15f-4170-4b28-b111-191cd567c347', | ||
'67890'); | ||
INSERT INTO barcodes.barcode (barcode, kit_id) | ||
VALUES ('00001234', 'test1'); | ||
""" | ||
with t.cursor() as cur: | ||
cur.execute(setup_sql) | ||
|
||
admin_repo = AdminRepo(t) | ||
|
||
barcodes = admin_repo.get_barcodes_filter( | ||
inbound_tracking_numbers=['67890']) | ||
self.assertEqual(barcodes, ['00001234']) | ||
|
||
def test_get_barcodes_filter_inbound_tracking_failure(self): | ||
with Transaction() as t: | ||
admin_repo = AdminRepo(t) | ||
barcodes = admin_repo.get_barcodes_filter( | ||
inbound_tracking_numbers=['99999']) | ||
self.assertEqual(barcodes, []) | ||
|
||
def test_get_kit_by_barcode_success(self): | ||
with Transaction() as t: | ||
setup_sql = """ | ||
INSERT INTO barcodes.kit (kit_id, box_id) | ||
VALUES ('test1', '0001e15f-4170-4b28-b111-191cd567c348'); | ||
INSERT INTO barcodes.barcode (barcode, kit_id) | ||
VALUES ('00001234', 'test1'); | ||
""" | ||
with t.cursor() as cur: | ||
cur.execute(setup_sql) | ||
|
||
admin_repo = AdminRepo(t) | ||
|
||
kit_info = admin_repo.get_kit_by_barcode(['00001234']) | ||
expected = [{ | ||
'barcode': '00001234', | ||
'outbound_tracking': None, | ||
'inbound_tracking': None, | ||
'kit_id': 'test1' | ||
}] | ||
self.assertEqual(kit_info, expected) | ||
|
||
def test_get_kit_by_barcode_failure(self): | ||
with Transaction() as t: | ||
admin_repo = AdminRepo(t) | ||
kit_info = admin_repo.get_kit_by_barcode(['nonexistent_barcode']) | ||
self.assertIsNone(kit_info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters