diff --git a/.github/workflows/scrape.yml b/.github/workflows/scrape.yml deleted file mode 100644 index ef0ed7f..0000000 --- a/.github/workflows/scrape.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: Scrape data for active agencies - -on: - workflow_dispatch: - schedule: - # every day at 6am UTC, 10-11pm Pacific - - cron: "0 6 * * *" - -defaults: - run: - shell: bash - -jobs: - scrape: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - participant: [mst, sacrt, sbmtd] - - steps: - - uses: actions/checkout@v4 - - - name: Install the littlepay library - run: | - python3 -m pip install --upgrade pip - pip install -e . - - - name: Create config file and set participant - # the LITTLEPAY_CONFIG secret only contains configuration for the prod env - # the prod env is already activated, with no participant yet activated - run: | - cat > .config/scrape.yaml <<- EOM - ${{ secrets.LITTLEPAY_CONFIG }} - EOM - littlepay config .config/scrape.yaml - littlepay switch participant ${{ matrix.participant }} - - - name: Get groups - run: littlepay groups --csv > data/${{ matrix.participant }}_groups.csv - - - name: Get products - run: littlepay products --csv > data/${{ matrix.participant }}_products.csv - - - name: Get group<>product associations - run: littlepay groups products --csv > data/${{ matrix.participant }}_linked_groups_products.csv - - - name: Upload data files as artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.participant }}-data - path: data/*.csv - if-no-files-found: ignore - overwrite: true - - commit: - runs-on: ubuntu-latest - needs: scrape - env: - # set the time zone for more readable $(date) output - TZ: America/Los_Angeles - - steps: - - uses: actions/checkout@v4 - with: - token: ${{ secrets.BOT_ACCESS_TOKEN }} - - - uses: actions/download-artifact@v4 - with: - path: data/ - # The downloaded artifacts will be in the same directory specified by path - # (rather than individual named directories within path) - merge-multiple: true - - - name: Check for modified data files - id: git-modified - run: echo modified=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi) >> "$GITHUB_OUTPUT" - - - name: Commit modified data files - if: steps.git-modified.outputs.modified == 'true' - run: | - git config user.name "Cal-ITP Bot" - git config user.email "bot@calitp.org" - git add data/ - git commit -m "chore(data): update files on $(date)" || exit 0 - git push diff --git a/README.md b/README.md index 19385aa..34b1544 100644 --- a/README.md +++ b/README.md @@ -100,16 +100,10 @@ The most recent config used is saved for next time. ### Switch the active target -For `envs`: +Use one or both of the `-e/--env` and `-p/--participant` flags: ```console -littlepay switch env -``` - -And `participants`: - -```console -littlepay switch participant +littlepay switch -e -p ``` ## Work with groups diff --git a/data/README.md b/data/README.md deleted file mode 100644 index 4c833f1..0000000 --- a/data/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# data - -This directory stores the current state of Products and Groups for agencies using -Littlepay supported by Cal-ITP and the [Benefits](https://github.com/cal-itp/benefits) team. diff --git a/data/mst_groups.csv b/data/mst_groups.csv deleted file mode 100644 index f785699..0000000 --- a/data/mst_groups.csv +++ /dev/null @@ -1,7 +0,0 @@ -id,label,participant_id -e919852a-5e47-478d-b4bc-7362ca3706e6,Courtesy Card discount group,mst -0a34494c-8800-4251-8065-b0310ff76cad,double-discount,mst -c1a1b1cb-c096-47c2-98d7-389d71c6b350,MST Visa Promo,mst -5170d37b-43d5-4049-899c-b4d850e14990,Senior discount group,mst -a3e334ef-14c8-4d47-9264-abcf66043ec0,senior-logingov-test,mst -ab9982fb-c2f8-4116-9ffb-ced0ca20bf25,Veteran discount group,mst diff --git a/data/mst_linked_groups_products.csv b/data/mst_linked_groups_products.csv deleted file mode 100644 index 6005316..0000000 --- a/data/mst_linked_groups_products.csv +++ /dev/null @@ -1,33 +0,0 @@ -group_id,product_id,participant_id -e919852a-5e47-478d-b4bc-7362ca3706e6,1b82328e-a308-4f8e-bb93-0a1a13e6c849,mst -e919852a-5e47-478d-b4bc-7362ca3706e6,2eb7d763-f9ae-4c25-9e1b-31c1516afb04,mst -e919852a-5e47-478d-b4bc-7362ca3706e6,380991bd-70d2-42ff-9219-cb105818bdde,mst -e919852a-5e47-478d-b4bc-7362ca3706e6,4f945c2e-7aad-4e1e-a3b0-043e92c055e9,mst -e919852a-5e47-478d-b4bc-7362ca3706e6,57bc4b52-bafa-4d7f-87ea-75170e14adff,mst -e919852a-5e47-478d-b4bc-7362ca3706e6,a8834819-826e-44be-9361-c989aa0fa4e3,mst -e919852a-5e47-478d-b4bc-7362ca3706e6,b7238083-b366-435e-ade1-48d04d593aaf,mst -e919852a-5e47-478d-b4bc-7362ca3706e6,cb07d634-da91-4cbf-b39d-a7351b82d327,mst -0a34494c-8800-4251-8065-b0310ff76cad,164f9d1b-c893-4a81-9021-56c1137c1914,mst -0a34494c-8800-4251-8065-b0310ff76cad,ecddbf3f-858f-4216-ba2f-37fef8b39d83,mst -c1a1b1cb-c096-47c2-98d7-389d71c6b350,0bb818c8-9958-43ad-b6df-d8c785dbc25f,mst -c1a1b1cb-c096-47c2-98d7-389d71c6b350,65a5909c-b4af-4ebc-aeb3-e293ee615236,mst -c1a1b1cb-c096-47c2-98d7-389d71c6b350,fe9f4746-8b13-41de-968c-67022c575a6f,mst -5170d37b-43d5-4049-899c-b4d850e14990,1b82328e-a308-4f8e-bb93-0a1a13e6c849,mst -5170d37b-43d5-4049-899c-b4d850e14990,2eb7d763-f9ae-4c25-9e1b-31c1516afb04,mst -5170d37b-43d5-4049-899c-b4d850e14990,380991bd-70d2-42ff-9219-cb105818bdde,mst -5170d37b-43d5-4049-899c-b4d850e14990,4f945c2e-7aad-4e1e-a3b0-043e92c055e9,mst -5170d37b-43d5-4049-899c-b4d850e14990,65a5909c-b4af-4ebc-aeb3-e293ee615236,mst -5170d37b-43d5-4049-899c-b4d850e14990,8b677ad8-ff4b-4b9a-acee-c3ee4e700d8d,mst -5170d37b-43d5-4049-899c-b4d850e14990,a8834819-826e-44be-9361-c989aa0fa4e3,mst -5170d37b-43d5-4049-899c-b4d850e14990,b7238083-b366-435e-ade1-48d04d593aaf,mst -5170d37b-43d5-4049-899c-b4d850e14990,cb07d634-da91-4cbf-b39d-a7351b82d327,mst -5170d37b-43d5-4049-899c-b4d850e14990,dcca279b-567e-4221-a708-880437be239e,mst -a3e334ef-14c8-4d47-9264-abcf66043ec0,2eb7d763-f9ae-4c25-9e1b-31c1516afb04,mst -a3e334ef-14c8-4d47-9264-abcf66043ec0,65a5909c-b4af-4ebc-aeb3-e293ee615236,mst -a3e334ef-14c8-4d47-9264-abcf66043ec0,a8834819-826e-44be-9361-c989aa0fa4e3,mst -a3e334ef-14c8-4d47-9264-abcf66043ec0,b7238083-b366-435e-ade1-48d04d593aaf,mst -ab9982fb-c2f8-4116-9ffb-ced0ca20bf25,1b82328e-a308-4f8e-bb93-0a1a13e6c849,mst -ab9982fb-c2f8-4116-9ffb-ced0ca20bf25,380991bd-70d2-42ff-9219-cb105818bdde,mst -ab9982fb-c2f8-4116-9ffb-ced0ca20bf25,4f945c2e-7aad-4e1e-a3b0-043e92c055e9,mst -ab9982fb-c2f8-4116-9ffb-ced0ca20bf25,cb07d634-da91-4cbf-b39d-a7351b82d327,mst -ab9982fb-c2f8-4116-9ffb-ced0ca20bf25,dcff72c9-a8e3-493b-895d-ef95dbff5152,mst diff --git a/data/mst_products.csv b/data/mst_products.csv deleted file mode 100644 index daf57f8..0000000 --- a/data/mst_products.csv +++ /dev/null @@ -1,79 +0,0 @@ -id,code,status,type,description,participant_id -020eed3c-615e-4783-affe-146f06854cfd,CAPPING,ACTIVE,CAPPING,Weekly Cap $50,mst -0b06b4bd-2429-4d2b-98e7-fc454b09846c,CAPPING,INACTIVE,CAPPING,Monthly Cap,mst -0bb818c8-9958-43ad-b6df-d8c785dbc25f,2 Hour VISA Cap Discount,ACTIVE,CAPPING,2 Hour VISA Cap Discount,mst -0d9f2abe-3fad-4ddb-8e48-95240667041a,CAPPING,ACTIVE,CAPPING,Weekly Cap $50,mst -10c14879-de54-487a-a24f-0107f516cdf3,Monthly Discount $47,INACTIVE,CAPPING,Monthly Discount $47,mst -164f9d1b-c893-4a81-9021-56c1137c1914,2 Hour VISA and Senior Cap Discount,ACTIVE,CAPPING,2 Hour VISA and Senior Cap Discount,mst -1b82328e-a308-4f8e-bb93-0a1a13e6c849,7 Day Cap Discount,ACTIVE,CAPPING,7 Day Cap Discount,mst -2eb7d763-f9ae-4c25-9e1b-31c1516afb04,Monthly Discount $47,ACTIVE,CAPPING,Monthly Discount $47,mst -335c7387-0d14-4858-a59a-3314407608f4,CAPPING - DISCOUNT WEEKLY,ACTIVE,CAPPING,Weekly Discount Capping,mst -33a2785d-6819-495e-a18d-7ba91ee7f980,CAPPING - DISCOUNT DAILY,ACTIVE,CAPPING,DAILY DISCOUNT CAPPING,mst -380991bd-70d2-42ff-9219-cb105818bdde,Day Cap Discount,ACTIVE,CAPPING,Day Cap Discount,mst -3caf3c71-37af-422c-84f2-523399ffbba0,CAPPING,INACTIVE,CAPPING,Weekly Cap,mst -3fe544bd-69a3-4e2f-85e7-6454be5380a1,Monthly Discount $47,ACTIVE,CAPPING,Monthly Discount $47,mst -405f5975-bf31-4faa-bf1c-43a36057bbcf,Weekly Discount $25,INACTIVE,CAPPING,Weekly Discount $25,mst -417cacf9-7ece-4e40-8c67-29665e648935,CAPPING - DISCOUNT WEEKLY,ACTIVE,CAPPING,WEEKLY DISCOUNT CAPPING,mst -48012ec4-5951-48f0-b078-9a8311188919,2 Hour VISA and Senior Cap Discount,INACTIVE,CAPPING,2 Hour VISA and Senior Cap Discount,mst -4add9e66-1e1d-4791-b6fd-5f28603ecc31,CAPPING,ACTIVE,CAPPING,Monthly Cap $95,mst -4c0b185a-ab0e-4562-b99b-999fcf7f279c,MST-DailyCAP-1,ACTIVE,CAPPING,Daily Cap $10 - MST,mst -4f945c2e-7aad-4e1e-a3b0-043e92c055e9,2 Hour Cap Discount,ACTIVE,CAPPING,2 Hour Cap Discount,mst -53074e03-06ca-4ad0-bc37-27275481f313,Weekly Discount $25,ACTIVE,CAPPING,Weekly Discount $25,mst -5a4974dc-1e99-4fd9-8444-1d376658679a,CAPPING - DISCOUNT DAILY,ACTIVE,CAPPING,DAILY DISCOUNT CAPPING,mst -5ac7e011-5563-40aa-ad8b-43a0bb621211,2 Hour VISA Cap Discount,ACTIVE,CAPPING,2 Hour VISA Cap Discount,mst -6e1476a7-02c3-4277-8f3d-98eea1fffe41,31 Day VISA and VISA-SENIOR Cap Discount,INACTIVE,CAPPING,31 Day VISA and VISA-SENIOR Cap Discount,mst -712fa1e9-7b0e-4646-88a7-f14f9f9bcc98,CAPPING - DISCOUNT MONTHLY,ACTIVE,CAPPING,MONTHLY DISCOUNT CAPPING,mst -7831f073-98a1-427b-adea-77336476b1ad,31 Day Cap,ACTIVE,CAPPING,31 Day Cap,mst -7c18161d-2bef-4524-8d62-d0cb29b58a48,Daily Discount $5,ACTIVE,CAPPING,Daily Discount $5,mst -7c7c1113-6c0a-499f-aace-3c81eb79135d,CAPPING - DISCOUNT MONTHLY,ACTIVE,CAPPING,MONTHLY DISCOUNT CAPPING,mst -807c13d5-f00b-4a02-ba40-b189be5f2955,CAPPING - DISCOUNT MONTHLY,ACTIVE,CAPPING,MONTHLY DISCOUNT CAPPING,mst -83a97ea6-fbf5-4609-b8f3-993f45531c71,Test - 2 Day Multiday,ACTIVE,CAPPING,2 Day Multiday Rule,mst -857f2877-42b1-44d5-ae92-ee5dbc69f951,CAPPING - DISCOUNT DAILY,ACTIVE,CAPPING,DAILY DISCOUNT CAPPING,mst -89b6bb47-6512-495e-afd4-565c18a8b94e,CAPPING,ACTIVE,CAPPING,Monthly Cap $95,mst -8cc77057-bf0c-4701-a70b-529bf1600ffe,Day Cap,ACTIVE,CAPPING,Day Cap,mst -93ba4445-81ce-4748-b3cf-1bc916512974,CAPPING - DISCOUNT DAILY,ACTIVE,CAPPING,DAILY DISCOUNT CAPPING,mst -9936d982-7261-4848-b6d5-8edcba50cb18,MST-DailyCAP-1,ACTIVE,CAPPING,Daily Cap $10 - MST,mst -99bbbc1a-df5a-41ef-80e6-62d00254c2db,CAPPING - DISCOUNT DAILY,ACTIVE,CAPPING,DAILY DISCOUNT CAPPING,mst -a0659f75-93aa-4f72-8726-40ef239004ce,CAPPING,INACTIVE,CAPPING,Weekly Cap,mst -a6bf7f90-eaca-4c31-8391-070f424b55aa,MST-DailyCAP-1,INACTIVE,CAPPING,Daily CAP - MST,mst -a7c93bbd-ef93-481f-8245-f46c82430046,MST-DailyCAP-1,INACTIVE,CAPPING,Daily CAP - MST,mst -a8834819-826e-44be-9361-c989aa0fa4e3,Weekly Discount $25,ACTIVE,CAPPING,Weekly Discount $25,mst -ab15fd20-5c39-49e9-94a4-bd178080ef20,CAPPING - DISCOUNT DAILY,ACTIVE,CAPPING,Daily Discount Capping,mst -ab772515-defb-4fec-be10-15e3cc8d6db7,2 Hour VISA and Senior Cap Discount,ACTIVE,CAPPING,2 Hour VISA and Senior Cap Discount,mst -b2297782-d57f-4479-ab8e-c5ef0d1b2177,CAPPING - DISCOUNT DAILY,ACTIVE,CAPPING,Daily Discount $5,mst -b7238083-b366-435e-ade1-48d04d593aaf,Daily Discount $5,ACTIVE,CAPPING,Daily Discount $5,mst -b7e7738f-64ce-43f9-8b37-118db30b4cb8,CAPPING,INACTIVE,CAPPING,Monthly Cap,mst -bd6c0c6e-d6cd-4cd1-9f36-9361178b4f2b,CAPPING,INACTIVE,CAPPING,Monthly Cap,mst -bfdbd175-2788-4690-bf57-12ca3a63459a,7 Day Cap,ACTIVE,CAPPING,7 Day Cap,mst -c4b025e6-0c05-4fcb-814c-6e9e93e128d2,CAPPING - DISCOUNT WEEKLY,ACTIVE,CAPPING,WEEKLY DISCOUNT CAPPING,mst -c821a792-f6c0-43a8-ac62-d8131a2c08b1,CAPPING,INACTIVE,CAPPING,Weekly Cap,mst -ca245beb-2d48-435f-b1ac-3753cb1941fd,CAPPING,INACTIVE,CAPPING,Weekly Cap,mst -cac6afcf-438d-42ed-ae1c-2bad8b9bb6c9,2 Hour Cap,ACTIVE,CAPPING,2 Hour Cap,mst -cb07d634-da91-4cbf-b39d-a7351b82d327,31 Day Cap Discount,ACTIVE,CAPPING,31 Day Cap Discount,mst -cd57a1d0-b2a6-49d7-b69e-4c01ac14dd4c,Weekly Discount $25,ACTIVE,CAPPING,Weekly Discount $25,mst -d1bb7cad-c1ef-427f-b59b-453de7d4a509,CAPPING,ACTIVE,CAPPING,Monthly Cap $95,mst -d56ad7f9-fead-4cb2-9729-69cc048b4ace,2 Hour VISA Cap Discount,INACTIVE,CAPPING,2 Hour VISA Cap Discount,mst -d6cfd5f8-9b0a-4f08-b14a-20550e974ed3,CAPPING,INACTIVE,CAPPING,Weekly Cap,mst -d7bef6ce-3276-465c-9507-3628d2a5633d,CAPPING - DISCOUNT MONTHLY,ACTIVE,CAPPING,Monthly Discount $47,mst -dd136fc5-b60a-4617-923d-f44e8ac5785b,CAPPING - DISCOUNT DAILY,ACTIVE,CAPPING,Daily Discount $5,mst -deb01679-b77e-452f-8261-c8840de2d60a,CAPPING - DISCOUNT DAILY,ACTIVE,CAPPING,DAILY DISCOUNT CAPPING,mst -e23bbaf0-b443-40ae-94c9-aafd3a09bd82,Monthly Discount $47,ACTIVE,CAPPING,Monthly Discount $47,mst -e41c7359-6ada-4d85-86ee-270ea7387a9e,CAPPING - DISCOUNT MONTHLY,ACTIVE,CAPPING,Monthly Discount Capping,mst -e67b1c36-9aab-49c8-8d29-bd83f4bea224,CAPPING,INACTIVE,CAPPING,Weekly Cap,mst -f3329af7-e6d3-4c79-9983-8509ec0f77da,Test - 2 Day Multiday,ACTIVE,CAPPING,2 Day Multiday Rule,mst -f56deee4-571b-4e27-9006-51208ca1dfad,CAPPING - DISCOUNT WEEKLY,ACTIVE,CAPPING,Weekly Discount $25,mst -f739063e-6dd3-4544-843d-f671b0c4e448,CAPPING - DISCOUNT WEEKLY,ACTIVE,CAPPING,Weekly Discount $25,mst -fe18f445-8cc6-4c72-8b41-c95fec22c352,Daily Discount $5,INACTIVE,CAPPING,Daily Discount $5,mst -1fd5507b-8a82-4618-ad8e-085736a31477,Visa and Senior Discount,ACTIVE,DISCOUNT,Visa and Senior Discount,mst -2fed7e82-ca0b-4528-b424-b544fb8c2a54,Visa Discount,ACTIVE,DISCOUNT,Visa Discount,mst -3766c378-77db-47de-9e8e-66b05c76f064,VETDISC,ACTIVE,DISCOUNT,Veterans Discount Fare,mst -49009e87-452d-461f-8f57-7d95aa43d144,MST VISA Discount,ACTIVE,DISCOUNT,MST VISA Discount,mst -57bc4b52-bafa-4d7f-87ea-75170e14adff,CCDISC,ACTIVE,DISCOUNT,Courtesy Card Discount Fare,mst -65a5909c-b4af-4ebc-aeb3-e293ee615236,DISCOUNT FARE,ACTIVE,DISCOUNT,Discount Fare,mst -6e99820c-665e-41f0-8b54-dee64b42d5d8,Visa and Senior Discount,ACTIVE,DISCOUNT,Visa and Senior Discount,mst -8b677ad8-ff4b-4b9a-acee-c3ee4e700d8d,SRDISC,ACTIVE,DISCOUNT,Senior Discount Fare,mst -af0aa303-39d2-47f8-b546-3eb4ed02814b,Visa and Senior Discount,ACTIVE,DISCOUNT,Visa and Senior Discount,mst -dcca279b-567e-4221-a708-880437be239e,SRDISC,ACTIVE,DISCOUNT,Senior Discount Fare,mst -dcff72c9-a8e3-493b-895d-ef95dbff5152,VETDISC,ACTIVE,DISCOUNT,Veterans Discount Fare,mst -ecddbf3f-858f-4216-ba2f-37fef8b39d83,Visa and Senior Discount,ACTIVE,DISCOUNT,Visa and Senior Discount,mst -fe9f4746-8b13-41de-968c-67022c575a6f,Visa Discount,ACTIVE,DISCOUNT,Visa Discount,mst diff --git a/data/sacrt_groups.csv b/data/sacrt_groups.csv deleted file mode 100644 index 4167544..0000000 --- a/data/sacrt_groups.csv +++ /dev/null @@ -1,2 +0,0 @@ -id,label,participant_id -80271c54-29f6-465c-ad33-0f6ef18a15be,(Prod) Test Group 0,sacrt diff --git a/data/sacrt_linked_groups_products.csv b/data/sacrt_linked_groups_products.csv deleted file mode 100644 index cc060d9..0000000 --- a/data/sacrt_linked_groups_products.csv +++ /dev/null @@ -1,4 +0,0 @@ -group_id,product_id,participant_id -80271c54-29f6-465c-ad33-0f6ef18a15be,11c14bb6-2469-42f6-867c-52b83752b03d,sacrt -80271c54-29f6-465c-ad33-0f6ef18a15be,bb2eebbb-8dc1-476f-9f8d-481817fdee3d,sacrt -80271c54-29f6-465c-ad33-0f6ef18a15be,ddaad296-8e75-46c2-af26-1b4207a930f9,sacrt diff --git a/data/sacrt_products.csv b/data/sacrt_products.csv deleted file mode 100644 index 53aafd0..0000000 --- a/data/sacrt_products.csv +++ /dev/null @@ -1,21 +0,0 @@ -id,code,status,type,description,participant_id -11c14bb6-2469-42f6-867c-52b83752b03d,DISC001,ACTIVE,CAPPING,Senior Discount 90 min Cap,sacrt -1fd44d59-08d1-44b2-bc36-c613055b8da4,DISC001,INACTIVE,CAPPING,Senior Discount Single Ride,sacrt -331b2ae2-126b-48a8-9944-3089c1ccc631,DISC001,ACTIVE,CAPPING,Senior Discount Single Ride,sacrt -3a2159d0-2893-4a8b-a71d-80de36dc8137,SacRT-90MIN,ACTIVE,CAPPING,SacRT-90MIN,sacrt -65bafff9-600b-463f-968a-57ff34ca5f9d,SacRT-90MIN,ACTIVE,CAPPING,SacRT-90MIN,sacrt -6815918c-b680-4a7d-a058-68f41849138f,DISC001,ACTIVE,CAPPING,Senior Discount Daily Cap,sacrt -68fc6210-7338-400a-9b00-ad4ddddac71e,SacRT-90MIN,INACTIVE,CAPPING,SacRT-90MIN,sacrt -a4ff0cd8-4073-472e-ae41-e32ca419b022,DISC001,ACTIVE,CAPPING,Senior Discount Single Ride,sacrt -aafa92ee-1c93-489d-ab24-5b3db786ef12,SACRT-Daily cap,ACTIVE,CAPPING,SACRT-Daily cap,sacrt -c0581fff-5365-4aa0-a2bd-c452b11a9cd6,DISC001,ACTIVE,CAPPING,Senior Discount 90 min Cap,sacrt -cc724bb1-a2e0-4be9-b3d3-8a6630e13516,SACRT-Daily cap,ACTIVE,CAPPING,SACRT-Daily cap,sacrt -d4d18eba-5d1c-416a-ae3e-bf18b04596cf,SacRT-90MIN,ACTIVE,CAPPING,SacRT-90MIN,sacrt -d6c36d07-7793-42c8-8c42-86a8785dc0b9,SACRT-Daily cap,INACTIVE,CAPPING,SACRT-Daily cap,sacrt -d8b39674-831e-4737-8033-4ba514a8c21f,DISC001,ACTIVE,CAPPING,Senior Discount 90 min Cap,sacrt -ddaad296-8e75-46c2-af26-1b4207a930f9,DISC001,ACTIVE,CAPPING,Senior Discount Daily Cap,sacrt -f083ca1c-3d41-4eb5-8a4f-a025b9774dcd,DISC001,INACTIVE,CAPPING,Senior Discount Single Ride,sacrt -f49b4192-2c0a-432d-9dc5-fd9784491989,SACRT-Daily cap,ACTIVE,CAPPING,SACRT-Daily cap,sacrt -3d42cb33-9de7-4784-b59b-7f8109573a8d,DISC001,ACTIVE,DISCOUNT,Senior Discount Single Ride,sacrt -44c5e773-e064-4609-88df-4437291c2266,DISC001,INACTIVE,DISCOUNT,Senior Discount Single Ride,sacrt -bb2eebbb-8dc1-476f-9f8d-481817fdee3d,DISC001,ACTIVE,DISCOUNT,Senior Discount Single Ride,sacrt diff --git a/data/sbmtd_groups.csv b/data/sbmtd_groups.csv deleted file mode 100644 index 342e8bc..0000000 --- a/data/sbmtd_groups.csv +++ /dev/null @@ -1,5 +0,0 @@ -id,label,participant_id -8bd969bd-89ac-41b3-a905-589f3d2b1027,Benefits Edenred Concession Group,sbmtd -ce3d04bf-3c51-4f4c-9779-82e5a02dc73a,Mobility Pass,sbmtd -46e95628-b4ad-4b36-b2b2-abb6b1acd10a,Older Adults,sbmtd -997cd423-c6a6-438d-a768-bd6555bd553e,SBCC Students Concession Group,sbmtd diff --git a/data/sbmtd_linked_groups_products.csv b/data/sbmtd_linked_groups_products.csv deleted file mode 100644 index cd7f893..0000000 --- a/data/sbmtd_linked_groups_products.csv +++ /dev/null @@ -1,8 +0,0 @@ -group_id,product_id,participant_id -8bd969bd-89ac-41b3-a905-589f3d2b1027,3bc7b9b0-e69f-4e8a-ac15-caa3cdf0a85e,sbmtd -ce3d04bf-3c51-4f4c-9779-82e5a02dc73a,6ed395ba-7fb0-484d-ae20-70f6e544e749,sbmtd -ce3d04bf-3c51-4f4c-9779-82e5a02dc73a,e520f25b-c815-4b2b-b569-3ca7bff3ce1f,sbmtd -ce3d04bf-3c51-4f4c-9779-82e5a02dc73a,ed0f4f0a-3d86-4a65-84bc-2af62f20ef94,sbmtd -46e95628-b4ad-4b36-b2b2-abb6b1acd10a,5c9e2890-af63-4faf-adb0-71dfd949882a,sbmtd -46e95628-b4ad-4b36-b2b2-abb6b1acd10a,65d2b799-f41b-4b4d-8f12-a6bd413a645f,sbmtd -46e95628-b4ad-4b36-b2b2-abb6b1acd10a,ed0f4f0a-3d86-4a65-84bc-2af62f20ef94,sbmtd diff --git a/data/sbmtd_products.csv b/data/sbmtd_products.csv deleted file mode 100644 index 1d1bf86..0000000 --- a/data/sbmtd_products.csv +++ /dev/null @@ -1,30 +0,0 @@ -id,code,status,type,description,participant_id -040a6f25-92dd-4dcb-a3fb-649f554ea97e,Time capping,ACTIVE,CAPPING,Time capping,sbmtd -09fd2982-7ff9-4f42-b4b5-9a7829921696,Daily Cap,ACTIVE,CAPPING,Daily Cap,sbmtd -0d671a2c-2f72-447c-97f6-481a0a44e4ed,Disabled 30 Day,ACTIVE,CAPPING,SBMTD Disabled Fare 30 Day,sbmtd -128f994f-0af3-4535-af1e-654264982fd5,UCSB TAP Employee Discount,INACTIVE,CAPPING,31dollar cap,sbmtd -1392c409-1e4d-48ea-8856-6b68fc577bb8,UCSB TAP Employee Discount,ACTIVE,CAPPING,31dollar cap,sbmtd -2807ba97-ae0a-4c14-9835-ff25081ca9eb,Disabled 30 Day,INACTIVE,CAPPING,SBMTD Disabled Fare 30 Day,sbmtd -3bc7b9b0-e69f-4e8a-ac15-caa3cdf0a85e,UCSB TAP Employee Discount,ACTIVE,CAPPING,31dollar cap,sbmtd -3d9cb34c-c94c-491e-b9bd-e4e2362cd278,Discount Time capping,ACTIVE,CAPPING,Discount Time capping,sbmtd -574ce184-591c-406f-aaed-dfe34c8dfc2e,Daily Cap,ACTIVE,CAPPING,Daily Cap,sbmtd -5e659c14-b7ad-4983-80eb-2cc63fc67439,Senior 65+ 30 Day,INACTIVE,CAPPING,SBMTD Senior 65+ Fare 30 Day,sbmtd -65d2b799-f41b-4b4d-8f12-a6bd413a645f,Senior 65+ 30 Day,ACTIVE,CAPPING,SBMTD Senior 65+ Fare 30 Day,sbmtd -66c87198-f0d0-416a-b866-0ed1ded33f65,Multi Day,ACTIVE,CAPPING,Multi Day,sbmtd -70e7d5fc-43c7-40c1-8113-88c47da4f025,Multi Day,ACTIVE,CAPPING,Multi Day,sbmtd -8c5747c8-f95b-4994-ba7b-d06db7a8e5b5,Multi Day Test,ACTIVE,CAPPING,Multi Day Test,sbmtd -accea115-a910-49a3-93dd-65a8b2a12822,Time capping,ACTIVE,CAPPING,Time capping,sbmtd -b56a7d42-63de-4dd9-91b6-64dc7ffefbbd,Time capping,ACTIVE,CAPPING,Time capping,sbmtd -ccba6d11-a618-4a57-a043-bd380805eadd,Time capping test,ACTIVE,CAPPING,Time capping test,sbmtd -ce306980-9a29-4396-9869-bfeaeb82ba04,Time capping,ACTIVE,CAPPING,Time capping,sbmtd -d55b68e1-0d7e-4b77-a512-15aa71a2db27,UCSB TAP Employee Discount,ACTIVE,CAPPING,31dollar cap,sbmtd -e520f25b-c815-4b2b-b569-3ca7bff3ce1f,Disabled 30 Day,ACTIVE,CAPPING,SBMTD Disabled Fare 30 Day,sbmtd -ed0f4f0a-3d86-4a65-84bc-2af62f20ef94,Time capping discount,ACTIVE,CAPPING,Time capping discount,sbmtd -f1bc214d-7230-44a2-9041-d546cbbb88aa,Daily Cap Test,ACTIVE,CAPPING,Daily Cap Test,sbmtd -fcc1b976-f55f-4aa4-b660-8ce81cdd9262,Senior 65+ 30 Day,ACTIVE,CAPPING,SBMTD Senior 65+ Fare 30 Day,sbmtd -05e4daf0-7bec-420f-9460-1704ac263d86,SBCCStudent,ACTIVE,DISCOUNT,SBCCStudentTap,sbmtd -0eabf1bb-8a77-4cdc-a9a0-8bdc37746837,Person with Disabilities,ACTIVE,DISCOUNT,SBMTD Disabled Fare,sbmtd -3e82b935-4d45-4207-9b6a-e6999ae1caea,Senior 65+,ACTIVE,DISCOUNT,SBMTD Senior 65+ Fare,sbmtd -5c9e2890-af63-4faf-adb0-71dfd949882a,Senior 65+,ACTIVE,DISCOUNT,SBMTD Senior 65+ Fare,sbmtd -6ed395ba-7fb0-484d-ae20-70f6e544e749,Person with Disabilities,ACTIVE,DISCOUNT,SBMTD Disabled Fare,sbmtd -ca0f94e8-166d-44c3-ac91-efda8ae552f6,Senior 65+,ACTIVE,DISCOUNT,SBMTD Senior 65+ Fare,sbmtd diff --git a/littlepay/commands/switch.py b/littlepay/commands/switch.py index ad0d5e5..d92ae5d 100644 --- a/littlepay/commands/switch.py +++ b/littlepay/commands/switch.py @@ -1,16 +1,16 @@ from littlepay.commands.configure import configure -from littlepay.config import CONFIG_TYPES, Config +from littlepay.config import Config -def switch(switch_type: str, switch_arg: str) -> int: - if switch_type not in CONFIG_TYPES: - raise ValueError(f"Unsupported type: {switch_type}, must be one of: {', '.join(CONFIG_TYPES)}") +def switch(env: str = None, participant: str = None) -> int: + if not (participant or env): + raise ValueError("Unsupported type: provide at least one of participant or env.") config = Config() - if switch_type == "env": - config.active_env_name = switch_arg - elif switch_type == "participant": - config.active_participant_id = switch_arg + if env: + config.active_env_name = env + if participant: + config.active_participant_id = participant return configure() diff --git a/littlepay/config.py b/littlepay/config.py index 579202c..6f63179 100644 --- a/littlepay/config.py +++ b/littlepay/config.py @@ -18,7 +18,6 @@ "envs": {ENV_QA: DEFAULT_ENV, ENV_PROD: DEFAULT_ENV}, "participants": {"cst": {ENV_QA: DEFAULT_CREDENTIALS, ENV_PROD: DEFAULT_CREDENTIALS}}, } -CONFIG_TYPES = list(DEFAULT_ACTIVE.keys()) def _ensure_current_exists() -> bool: diff --git a/littlepay/main.py b/littlepay/main.py index b049662..e39e983 100644 --- a/littlepay/main.py +++ b/littlepay/main.py @@ -7,7 +7,7 @@ from littlepay.commands.groups import groups from littlepay.commands.products import products from littlepay.commands.switch import switch -from littlepay.config import CONFIG_TYPES, Config +from littlepay.config import Config def _subcmd(subparsers: _SubParsersAction, name: str, help: str) -> ArgumentParser: @@ -113,10 +113,10 @@ def _maincmd(name, help): products_unlink = _subcmd(products_commands, "unlink", help="Unlink a concession group from one or more products") products_unlink.add_argument("group_id", help="The ID of the concession group to unlink") - # littlepay switch {env, participant} VALUE + # littlepay switch [[--env VALUE], [--participant VALUE]] switch_parser = _maincmd("switch", help="Switch the active environment or participant") - switch_parser.add_argument("switch_type", choices=CONFIG_TYPES, help="The type of object to switch", metavar="TYPE") - switch_parser.add_argument("switch_arg", help="The new object value", metavar="VALUE") + switch_parser.add_argument("-e", "--env", help="The environment to switch to") + switch_parser.add_argument("-p", "--participant", help="The participant to switch to") args = main_parser.parse_args(argv) @@ -127,7 +127,7 @@ def _maincmd(name, help): elif args.command == "products": return products(args) elif args.command == "switch": - return switch(args.switch_type, args.switch_arg) + return switch(args.env, args.participant) else: main_parser.print_help() return RESULT_FAILURE diff --git a/tests/commands/test_switch.py b/tests/commands/test_switch.py index fd69e29..fbcc839 100644 --- a/tests/commands/test_switch.py +++ b/tests/commands/test_switch.py @@ -26,31 +26,38 @@ def sample_config(custom_config_file: Path) -> dict: def test_switch_env(mock_commands_config): assert Config().active_env_name == "e1" - res = switch(switch_type="env", switch_arg="e2") + assert Config().active_participant_id == "p1" + res = switch(env="e2") assert res == RESULT_SUCCESS mock_commands_config.assert_called_once_with() - assert Config().active_env_name != "e1" assert Config().active_env_name == "e2" + assert Config().active_participant_id == "p1" def test_switch_participant(mock_commands_config): + assert Config().active_env_name == "e1" assert Config().active_participant_id == "p1" - res = switch(switch_type="participant", switch_arg="p2") + res = switch(participant="p2") assert res == RESULT_SUCCESS mock_commands_config.assert_called_once_with() - assert Config().active_participant_id != "p1" + assert Config().active_env_name == "e1" assert Config().active_participant_id == "p2" -def test_switch_unrecognized_type(mock_commands_config): - env = Config().active_env_name - participant = Config().active_participant_id +def test_switch_both(mock_commands_config): + assert Config().active_env_name == "e1" + assert Config().active_participant_id == "p1" - with pytest.raises(ValueError): - switch(switch_type="unrecognized", switch_arg="new_value") + res = switch(env="e2", participant="p2") - assert Config().active_env_name == env - assert Config().active_participant_id == participant - assert mock_commands_config.call_count == 0 + assert res == RESULT_SUCCESS + mock_commands_config.assert_called_once_with() + assert Config().active_env_name == "e2" + assert Config().active_participant_id == "p2" + + +def test_switch_none(): + with pytest.raises(ValueError): + switch() diff --git a/tests/test_main.py b/tests/test_main.py index e782fed..acad9fd 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -5,7 +5,7 @@ import pytest from littlepay.commands import RESULT_FAILURE, RESULT_SUCCESS -from littlepay.config import CONFIG_TYPES, Config +from littlepay.config import Config import littlepay.main from littlepay.main import main, __name__ as MODULE @@ -270,24 +270,38 @@ def test_main_products_status_unrecognized(mock_commands_products, status_flag): assert mock_commands_products.call_count == 0 -@pytest.mark.parametrize("switch_type", CONFIG_TYPES) -def test_main_switch_recognized_type(mock_commands_switch, switch_type): - result = main(argv=["switch", switch_type, "new_value"]) +@pytest.mark.parametrize("switch_arg", ["-e", "--env"]) +def test_main_switch_env(mock_commands_switch, switch_arg): + result = main(argv=["switch", switch_arg, "new_value"]) assert result == RESULT_SUCCESS - mock_commands_switch.assert_called_once_with(switch_type, "new_value") + mock_commands_switch.assert_called_once_with("new_value", None) -def test_main_switch_missing_value(mock_commands_switch): - with pytest.raises(SystemExit): - main(argv=["switch", "env"]) +@pytest.mark.parametrize("switch_arg", ["-p", "--participant"]) +def test_main_switch_participant(mock_commands_switch, switch_arg): + result = main(argv=["switch", switch_arg, "new_value"]) - assert mock_commands_switch.call_count == 0 + assert result == RESULT_SUCCESS + mock_commands_switch.assert_called_once_with(None, "new_value") + + +@pytest.mark.parametrize( + "switch_args", + [["-e", "env", "-p", "participant"], ["--env", "env", "--participant", "participant"]], +) +def test_main_switch_both(mock_commands_switch, switch_args): + argv = ["switch"] + switch_args + result = main(argv=argv) + + assert result == RESULT_SUCCESS + mock_commands_switch.assert_called_once_with("env", "participant") -def test_main_switch_unrecognized_type(mock_commands_switch): +@pytest.mark.parametrize("switch_type", ["-e", "--env", "-p", "--participant"]) +def test_main_switch_missing_value(mock_commands_switch, switch_type): with pytest.raises(SystemExit): - main(argv=["switch", "unrecognized", "new_value"]) + main(argv=["switch", switch_type]) assert mock_commands_switch.call_count == 0