From 1da5837669f2f9928383b293e02f2d427e122eed Mon Sep 17 00:00:00 2001 From: JD Rudie Date: Sun, 18 Aug 2024 23:52:19 -0400 Subject: [PATCH 1/6] feat: add some tests for gtfs --- poetry.lock | 119 ++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 2 + src/tests/test_gtfs.py | 61 +++++++++++++++++++++ 3 files changed, 180 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index 4a8145e..30de83e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "attrs" @@ -270,6 +270,90 @@ files = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +[[package]] +name = "coverage" +version = "7.6.1" +description = "Code coverage measurement for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "coverage-7.6.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b06079abebbc0e89e6163b8e8f0e16270124c154dc6e4a47b413dd538859af16"}, + {file = "coverage-7.6.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cf4b19715bccd7ee27b6b120e7e9dd56037b9c0681dcc1adc9ba9db3d417fa36"}, + {file = "coverage-7.6.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e61c0abb4c85b095a784ef23fdd4aede7a2628478e7baba7c5e3deba61070a02"}, + {file = "coverage-7.6.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fd21f6ae3f08b41004dfb433fa895d858f3f5979e7762d052b12aef444e29afc"}, + {file = "coverage-7.6.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f59d57baca39b32db42b83b2a7ba6f47ad9c394ec2076b084c3f029b7afca23"}, + {file = "coverage-7.6.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:a1ac0ae2b8bd743b88ed0502544847c3053d7171a3cff9228af618a068ed9c34"}, + {file = "coverage-7.6.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:e6a08c0be454c3b3beb105c0596ebdc2371fab6bb90c0c0297f4e58fd7e1012c"}, + {file = "coverage-7.6.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:f5796e664fe802da4f57a168c85359a8fbf3eab5e55cd4e4569fbacecc903959"}, + {file = "coverage-7.6.1-cp310-cp310-win32.whl", hash = "sha256:7bb65125fcbef8d989fa1dd0e8a060999497629ca5b0efbca209588a73356232"}, + {file = "coverage-7.6.1-cp310-cp310-win_amd64.whl", hash = "sha256:3115a95daa9bdba70aea750db7b96b37259a81a709223c8448fa97727d546fe0"}, + {file = "coverage-7.6.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7dea0889685db8550f839fa202744652e87c60015029ce3f60e006f8c4462c93"}, + {file = "coverage-7.6.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ed37bd3c3b063412f7620464a9ac1314d33100329f39799255fb8d3027da50d3"}, + {file = "coverage-7.6.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d85f5e9a5f8b73e2350097c3756ef7e785f55bd71205defa0bfdaf96c31616ff"}, + {file = "coverage-7.6.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9bc572be474cafb617672c43fe989d6e48d3c83af02ce8de73fff1c6bb3c198d"}, + {file = "coverage-7.6.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0c0420b573964c760df9e9e86d1a9a622d0d27f417e1a949a8a66dd7bcee7bc6"}, + {file = "coverage-7.6.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1f4aa8219db826ce6be7099d559f8ec311549bfc4046f7f9fe9b5cea5c581c56"}, + {file = "coverage-7.6.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:fc5a77d0c516700ebad189b587de289a20a78324bc54baee03dd486f0855d234"}, + {file = "coverage-7.6.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b48f312cca9621272ae49008c7f613337c53fadca647d6384cc129d2996d1133"}, + {file = "coverage-7.6.1-cp311-cp311-win32.whl", hash = "sha256:1125ca0e5fd475cbbba3bb67ae20bd2c23a98fac4e32412883f9bcbaa81c314c"}, + {file = "coverage-7.6.1-cp311-cp311-win_amd64.whl", hash = "sha256:8ae539519c4c040c5ffd0632784e21b2f03fc1340752af711f33e5be83a9d6c6"}, + {file = "coverage-7.6.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:95cae0efeb032af8458fc27d191f85d1717b1d4e49f7cb226cf526ff28179778"}, + {file = "coverage-7.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5621a9175cf9d0b0c84c2ef2b12e9f5f5071357c4d2ea6ca1cf01814f45d2391"}, + {file = "coverage-7.6.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:260933720fdcd75340e7dbe9060655aff3af1f0c5d20f46b57f262ab6c86a5e8"}, + {file = "coverage-7.6.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07e2ca0ad381b91350c0ed49d52699b625aab2b44b65e1b4e02fa9df0e92ad2d"}, + {file = "coverage-7.6.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c44fee9975f04b33331cb8eb272827111efc8930cfd582e0320613263ca849ca"}, + {file = "coverage-7.6.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:877abb17e6339d96bf08e7a622d05095e72b71f8afd8a9fefc82cf30ed944163"}, + {file = "coverage-7.6.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:3e0cadcf6733c09154b461f1ca72d5416635e5e4ec4e536192180d34ec160f8a"}, + {file = "coverage-7.6.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c3c02d12f837d9683e5ab2f3d9844dc57655b92c74e286c262e0fc54213c216d"}, + {file = "coverage-7.6.1-cp312-cp312-win32.whl", hash = "sha256:e05882b70b87a18d937ca6768ff33cc3f72847cbc4de4491c8e73880766718e5"}, + {file = "coverage-7.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:b5d7b556859dd85f3a541db6a4e0167b86e7273e1cdc973e5b175166bb634fdb"}, + {file = "coverage-7.6.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a4acd025ecc06185ba2b801f2de85546e0b8ac787cf9d3b06e7e2a69f925b106"}, + {file = "coverage-7.6.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a6d3adcf24b624a7b778533480e32434a39ad8fa30c315208f6d3e5542aeb6e9"}, + {file = "coverage-7.6.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d0c212c49b6c10e6951362f7c6df3329f04c2b1c28499563d4035d964ab8e08c"}, + {file = "coverage-7.6.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6e81d7a3e58882450ec4186ca59a3f20a5d4440f25b1cff6f0902ad890e6748a"}, + {file = "coverage-7.6.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78b260de9790fd81e69401c2dc8b17da47c8038176a79092a89cb2b7d945d060"}, + {file = "coverage-7.6.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a78d169acd38300060b28d600344a803628c3fd585c912cacc9ea8790fe96862"}, + {file = "coverage-7.6.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:2c09f4ce52cb99dd7505cd0fc8e0e37c77b87f46bc9c1eb03fe3bc9991085388"}, + {file = "coverage-7.6.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6878ef48d4227aace338d88c48738a4258213cd7b74fd9a3d4d7582bb1d8a155"}, + {file = "coverage-7.6.1-cp313-cp313-win32.whl", hash = "sha256:44df346d5215a8c0e360307d46ffaabe0f5d3502c8a1cefd700b34baf31d411a"}, + {file = "coverage-7.6.1-cp313-cp313-win_amd64.whl", hash = "sha256:8284cf8c0dd272a247bc154eb6c95548722dce90d098c17a883ed36e67cdb129"}, + {file = "coverage-7.6.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:d3296782ca4eab572a1a4eca686d8bfb00226300dcefdf43faa25b5242ab8a3e"}, + {file = "coverage-7.6.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:502753043567491d3ff6d08629270127e0c31d4184c4c8d98f92c26f65019962"}, + {file = "coverage-7.6.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6a89ecca80709d4076b95f89f308544ec8f7b4727e8a547913a35f16717856cb"}, + {file = "coverage-7.6.1-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a318d68e92e80af8b00fa99609796fdbcdfef3629c77c6283566c6f02c6d6704"}, + {file = "coverage-7.6.1-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13b0a73a0896988f053e4fbb7de6d93388e6dd292b0d87ee51d106f2c11b465b"}, + {file = "coverage-7.6.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:4421712dbfc5562150f7554f13dde997a2e932a6b5f352edcce948a815efee6f"}, + {file = "coverage-7.6.1-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:166811d20dfea725e2e4baa71fffd6c968a958577848d2131f39b60043400223"}, + {file = "coverage-7.6.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:225667980479a17db1048cb2bf8bfb39b8e5be8f164b8f6628b64f78a72cf9d3"}, + {file = "coverage-7.6.1-cp313-cp313t-win32.whl", hash = "sha256:170d444ab405852903b7d04ea9ae9b98f98ab6d7e63e1115e82620807519797f"}, + {file = "coverage-7.6.1-cp313-cp313t-win_amd64.whl", hash = "sha256:b9f222de8cded79c49bf184bdbc06630d4c58eec9459b939b4a690c82ed05657"}, + {file = "coverage-7.6.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6db04803b6c7291985a761004e9060b2bca08da6d04f26a7f2294b8623a0c1a0"}, + {file = "coverage-7.6.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f1adfc8ac319e1a348af294106bc6a8458a0f1633cc62a1446aebc30c5fa186a"}, + {file = "coverage-7.6.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a95324a9de9650a729239daea117df21f4b9868ce32e63f8b650ebe6cef5595b"}, + {file = "coverage-7.6.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b43c03669dc4618ec25270b06ecd3ee4fa94c7f9b3c14bae6571ca00ef98b0d3"}, + {file = "coverage-7.6.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8929543a7192c13d177b770008bc4e8119f2e1f881d563fc6b6305d2d0ebe9de"}, + {file = "coverage-7.6.1-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:a09ece4a69cf399510c8ab25e0950d9cf2b42f7b3cb0374f95d2e2ff594478a6"}, + {file = "coverage-7.6.1-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:9054a0754de38d9dbd01a46621636689124d666bad1936d76c0341f7d71bf569"}, + {file = "coverage-7.6.1-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:0dbde0f4aa9a16fa4d754356a8f2e36296ff4d83994b2c9d8398aa32f222f989"}, + {file = "coverage-7.6.1-cp38-cp38-win32.whl", hash = "sha256:da511e6ad4f7323ee5702e6633085fb76c2f893aaf8ce4c51a0ba4fc07580ea7"}, + {file = "coverage-7.6.1-cp38-cp38-win_amd64.whl", hash = "sha256:3f1156e3e8f2872197af3840d8ad307a9dd18e615dc64d9ee41696f287c57ad8"}, + {file = "coverage-7.6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:abd5fd0db5f4dc9289408aaf34908072f805ff7792632250dcb36dc591d24255"}, + {file = "coverage-7.6.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:547f45fa1a93154bd82050a7f3cddbc1a7a4dd2a9bf5cb7d06f4ae29fe94eaf8"}, + {file = "coverage-7.6.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:645786266c8f18a931b65bfcefdbf6952dd0dea98feee39bd188607a9d307ed2"}, + {file = "coverage-7.6.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9e0b2df163b8ed01d515807af24f63de04bebcecbd6c3bfeff88385789fdf75a"}, + {file = "coverage-7.6.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:609b06f178fe8e9f89ef676532760ec0b4deea15e9969bf754b37f7c40326dbc"}, + {file = "coverage-7.6.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:702855feff378050ae4f741045e19a32d57d19f3e0676d589df0575008ea5004"}, + {file = "coverage-7.6.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:2bdb062ea438f22d99cba0d7829c2ef0af1d768d1e4a4f528087224c90b132cb"}, + {file = "coverage-7.6.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:9c56863d44bd1c4fe2abb8a4d6f5371d197f1ac0ebdee542f07f35895fc07f36"}, + {file = "coverage-7.6.1-cp39-cp39-win32.whl", hash = "sha256:6e2cd258d7d927d09493c8df1ce9174ad01b381d4729a9d8d4e38670ca24774c"}, + {file = "coverage-7.6.1-cp39-cp39-win_amd64.whl", hash = "sha256:06a737c882bd26d0d6ee7269b20b12f14a8704807a01056c80bb881a4b2ce6ca"}, + {file = "coverage-7.6.1-pp38.pp39.pp310-none-any.whl", hash = "sha256:e9a6e0eb86070e8ccaedfbd9d38fec54864f3125ab95419970575b42af7541df"}, + {file = "coverage-7.6.1.tar.gz", hash = "sha256:953510dfb7b12ab69d20135a0662397f077c59b1e6379a768e97c59d852ee51d"}, +] + +[package.extras] +toml = ["tomli"] + [[package]] name = "ddsketch" version = "3.0.1" @@ -373,6 +457,37 @@ xmltodict = ">=0.12" openai = ["tiktoken"] opentracing = ["opentracing (>=2.0.0)"] +[[package]] +name = "debugpy" +version = "1.8.5" +description = "An implementation of the Debug Adapter Protocol for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "debugpy-1.8.5-cp310-cp310-macosx_12_0_x86_64.whl", hash = "sha256:7e4d594367d6407a120b76bdaa03886e9eb652c05ba7f87e37418426ad2079f7"}, + {file = "debugpy-1.8.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4413b7a3ede757dc33a273a17d685ea2b0c09dbd312cc03f5534a0fd4d40750a"}, + {file = "debugpy-1.8.5-cp310-cp310-win32.whl", hash = "sha256:dd3811bd63632bb25eda6bd73bea8e0521794cda02be41fa3160eb26fc29e7ed"}, + {file = "debugpy-1.8.5-cp310-cp310-win_amd64.whl", hash = "sha256:b78c1250441ce893cb5035dd6f5fc12db968cc07f91cc06996b2087f7cefdd8e"}, + {file = "debugpy-1.8.5-cp311-cp311-macosx_12_0_universal2.whl", hash = "sha256:606bccba19f7188b6ea9579c8a4f5a5364ecd0bf5a0659c8a5d0e10dcee3032a"}, + {file = "debugpy-1.8.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db9fb642938a7a609a6c865c32ecd0d795d56c1aaa7a7a5722d77855d5e77f2b"}, + {file = "debugpy-1.8.5-cp311-cp311-win32.whl", hash = "sha256:4fbb3b39ae1aa3e5ad578f37a48a7a303dad9a3d018d369bc9ec629c1cfa7408"}, + {file = "debugpy-1.8.5-cp311-cp311-win_amd64.whl", hash = "sha256:345d6a0206e81eb68b1493ce2fbffd57c3088e2ce4b46592077a943d2b968ca3"}, + {file = "debugpy-1.8.5-cp312-cp312-macosx_12_0_universal2.whl", hash = "sha256:5b5c770977c8ec6c40c60d6f58cacc7f7fe5a45960363d6974ddb9b62dbee156"}, + {file = "debugpy-1.8.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c0a65b00b7cdd2ee0c2cf4c7335fef31e15f1b7056c7fdbce9e90193e1a8c8cb"}, + {file = "debugpy-1.8.5-cp312-cp312-win32.whl", hash = "sha256:c9f7c15ea1da18d2fcc2709e9f3d6de98b69a5b0fff1807fb80bc55f906691f7"}, + {file = "debugpy-1.8.5-cp312-cp312-win_amd64.whl", hash = "sha256:28ced650c974aaf179231668a293ecd5c63c0a671ae6d56b8795ecc5d2f48d3c"}, + {file = "debugpy-1.8.5-cp38-cp38-macosx_12_0_x86_64.whl", hash = "sha256:3df6692351172a42af7558daa5019651f898fc67450bf091335aa8a18fbf6f3a"}, + {file = "debugpy-1.8.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1cd04a73eb2769eb0bfe43f5bfde1215c5923d6924b9b90f94d15f207a402226"}, + {file = "debugpy-1.8.5-cp38-cp38-win32.whl", hash = "sha256:8f913ee8e9fcf9d38a751f56e6de12a297ae7832749d35de26d960f14280750a"}, + {file = "debugpy-1.8.5-cp38-cp38-win_amd64.whl", hash = "sha256:a697beca97dad3780b89a7fb525d5e79f33821a8bc0c06faf1f1289e549743cf"}, + {file = "debugpy-1.8.5-cp39-cp39-macosx_12_0_x86_64.whl", hash = "sha256:0a1029a2869d01cb777216af8c53cda0476875ef02a2b6ff8b2f2c9a4b04176c"}, + {file = "debugpy-1.8.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e84c276489e141ed0b93b0af648eef891546143d6a48f610945416453a8ad406"}, + {file = "debugpy-1.8.5-cp39-cp39-win32.whl", hash = "sha256:ad84b7cde7fd96cf6eea34ff6c4a1b7887e0fe2ea46e099e53234856f9d99a34"}, + {file = "debugpy-1.8.5-cp39-cp39-win_amd64.whl", hash = "sha256:7b0fe36ed9d26cb6836b0a51453653f8f2e347ba7348f2bbfe76bfeb670bfb1c"}, + {file = "debugpy-1.8.5-py2.py3-none-any.whl", hash = "sha256:55919dce65b471eff25901acf82d328bbd5b833526b6c1364bd5133754777a44"}, + {file = "debugpy-1.8.5.zip", hash = "sha256:b2112cfeb34b4507399d298fe7023a16656fc553ed5246536060ca7bd0e668d0"}, +] + [[package]] name = "deprecated" version = "1.2.14" @@ -1017,4 +1132,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "~3.12" -content-hash = "e8489a4a7d7ca90b209ccaffa08d6e42a4c772eddccbfd0d4a099d560e21b20a" +content-hash = "eafc933603b8084af644ee88295f82f4228223f9bf17040dfebee98182ebada0" diff --git a/pyproject.toml b/pyproject.toml index e2febcf..ef2275c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,8 @@ requests = "2.32.3" boto3 = "^1.34.148" ddtrace = "^2.9.3" python-json-logger = "^2.0.7" +coverage = "^7.6.1" +debugpy = "^1.8.5" [tool.poetry.dev-dependencies] pip = ">=24.0.0" diff --git a/src/tests/test_gtfs.py b/src/tests/test_gtfs.py index dcf5b59..b06c712 100644 --- a/src/tests/test_gtfs.py +++ b/src/tests/test_gtfs.py @@ -3,6 +3,7 @@ import numpy as np import pandas as pd import pathlib +import shutil from zoneinfo import ZoneInfo import gtfs @@ -31,6 +32,7 @@ def setUp(self): self.all_trips = pd.read_csv(DATA_DIR / "trips_mini.txt", dtype={"trip_short_name": str, "block_id": str}) + def test_add_gtfs_headways_batch(self): # expected stop info.... # 60063977,05:10:00,05:10:00,10003,5,,0,0,0,,, @@ -184,3 +186,62 @@ def test_add_gtfs_headways(self): post_df = gtfs.add_gtfs_headways(df, self.all_trips, self.stop_times) pd.testing.assert_frame_equal(post_df, expected_df) + + + # this is really more of an integration test... should we have an integration tests directory? + def test_get_gtfs_archive_day_is_feed_returns_dir_of_day(self): + # just a random day + + day_to_test: int = 20240807 + expected_path: str = f"data/gtfs_archives/{str(day_to_test)}" + + result = gtfs.get_gtfs_archive(day_to_test) + + assert str(result) == expected_path + assert pathlib.Path.exists(result) + + # cleanup + shutil.rmtree(expected_path) + + def test_get_gtfs_archive_day_not_feed_returns_dir_of_feed_containing_day(self): + # from https://cdn.mbta.com/archive/archived_feeds.txt + # 20240802,20240806,"Summer 2024, 2024-08-09T21:10:59+00:00, version D",https://cdn.mbtace.com/archive/20240802.zip,fix: Correct wrong-direction stop sequences etc in existing Ashmont-Mattapan shuttle definition; Add shuttle activation for 08/16-18 Mattapan shuttle; Replace Mattapan Line service during 08/16-18 suspension for track work; Add missing 25:00 info to shuttle activation; Fix formatting; Whoops! Change + day_to_test: int = 20240804 + expected_path: str = f"data/gtfs_archives/20240802" + + result = gtfs.get_gtfs_archive(day_to_test) + + assert str(result) == expected_path + assert pathlib.Path.exists(result) + + # cleanup + shutil.rmtree(expected_path) + + def test_read_gtfs_date_exists_feed_is_read(self): + day_to_test = datetime.date(2024, 8, 7) + expected_path: str = f"data/gtfs_archives/20240802" + + result = gtfs.read_gtfs(day_to_test) + + assert result.service_date == day_to_test + + orange_line_trips = result.trips_by_route_id('Orange') + assert not orange_line_trips.empty + + # sanity check we have trips for each termini of the orange line + assert "Forest Hills" in orange_line_trips["trip_headsign"].values + assert "Oak Grove" in orange_line_trips["trip_headsign"].values + + # sanity check stops exist for the red line + assert not result.stop_times_by_route_id('Red').empty + # red line has stop data for ashmont + assert '70094' in result.stop_times_by_route_id('Red')['stop_id'] + + # 10 bus has trips + assert not result.trips_by_route_id('10').empty + # it stopped at st james / dartmouth street + assert '178' in result.trips_by_route_id('10')['stop_id'] + + shutil.rmtree(expected_path) + + From 5cde47924c6864d59536e2aa5b7e3949916529d4 Mon Sep 17 00:00:00 2001 From: JD Rudie Date: Mon, 19 Aug 2024 08:19:26 -0400 Subject: [PATCH 2/6] fixup: fix tests --- src/gtfs.py | 3 ++- src/tests/test_gtfs.py | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gtfs.py b/src/gtfs.py index 6cd513c..82459b4 100644 --- a/src/gtfs.py +++ b/src/gtfs.py @@ -338,10 +338,11 @@ def update_current_gtfs_archive_if_necessary(): current_gtfs_archive = read_gtfs(gtfs_service_date, routes_filter=ALL_ROUTES) -def get_current_gtfs_archive(): +def get_current_gtfs_archive() -> GtfsArchive: global current_gtfs_archive if current_gtfs_archive is None: update_current_gtfs_archive_if_necessary() + return current_gtfs_archive diff --git a/src/tests/test_gtfs.py b/src/tests/test_gtfs.py index b06c712..1dac940 100644 --- a/src/tests/test_gtfs.py +++ b/src/tests/test_gtfs.py @@ -219,7 +219,7 @@ def test_get_gtfs_archive_day_not_feed_returns_dir_of_feed_containing_day(self): def test_read_gtfs_date_exists_feed_is_read(self): day_to_test = datetime.date(2024, 8, 7) - expected_path: str = f"data/gtfs_archives/20240802" + expected_path: str = f"data/gtfs_archives/20240807" result = gtfs.read_gtfs(day_to_test) @@ -235,12 +235,11 @@ def test_read_gtfs_date_exists_feed_is_read(self): # sanity check stops exist for the red line assert not result.stop_times_by_route_id('Red').empty # red line has stop data for ashmont - assert '70094' in result.stop_times_by_route_id('Red')['stop_id'] + assert '70094' in result.stop_times_by_route_id('Red')['stop_id'].values - # 10 bus has trips - assert not result.trips_by_route_id('10').empty - # it stopped at st james / dartmouth street - assert '178' in result.trips_by_route_id('10')['stop_id'] + # the 1 bus has trips to harcard + assert not result.trips_by_route_id('1').empty + assert 'Harvard' in result.trips_by_route_id('1')['trip_headsign'].values shutil.rmtree(expected_path) From a7441015abd2ac7da59baf15de272d70d550b184 Mon Sep 17 00:00:00 2001 From: JD Rudie Date: Mon, 19 Aug 2024 08:52:26 -0400 Subject: [PATCH 3/6] fixup: more tests --- src/tests/test_util.py | 78 +++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/src/tests/test_util.py b/src/tests/test_util.py index 544609f..023f70c 100644 --- a/src/tests/test_util.py +++ b/src/tests/test_util.py @@ -1,29 +1,51 @@ from datetime import date, datetime -from util import EASTERN_TIME, service_date - - -def test_service_date(): - assert service_date(datetime(2023, 12, 15, 3, 0, 0)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 15, 5, 45, 0)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 15, 7, 15, 0)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 15, 23, 59, 59)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 16, 0, 0, 0)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 16, 2, 59, 59)) == date(2023, 12, 15) - - -def test_localized_datetime(): - assert service_date(datetime(2023, 12, 15, 3, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 15, 5, 45, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 15, 7, 15, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 15, 23, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 16, 0, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) - assert service_date(datetime(2023, 12, 16, 2, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) - - -def test_edt_vs_est_datetimes(): - assert service_date(datetime(2023, 11, 5, 23, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) - assert service_date(datetime(2023, 11, 6, 0, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) - assert service_date(datetime(2023, 11, 6, 1, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) - assert service_date(datetime(2023, 11, 6, 2, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) - # 3am EST is 4am EDT - assert service_date(datetime(2023, 11, 6, 3, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 6) +from util import EASTERN_TIME, output_dir_path, service_date, to_dateint +from unittest import TestCase + +class TestUtil(TestCase): + def test_service_date(self): + assert service_date(datetime(2023, 12, 15, 3, 0, 0)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 15, 5, 45, 0)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 15, 7, 15, 0)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 15, 23, 59, 59)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 16, 0, 0, 0)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 16, 2, 59, 59)) == date(2023, 12, 15) + + + def test_localized_datetime(self): + assert service_date(datetime(2023, 12, 15, 3, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 15, 5, 45, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 15, 7, 15, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 15, 23, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 16, 0, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) + assert service_date(datetime(2023, 12, 16, 2, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) + + + def test_edt_vs_est_datetimes(self): + assert service_date(datetime(2023, 11, 5, 23, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) + assert service_date(datetime(2023, 11, 6, 0, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) + assert service_date(datetime(2023, 11, 6, 1, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) + assert service_date(datetime(2023, 11, 6, 2, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) + # 3am EST is 4am EDT + assert service_date(datetime(2023, 11, 6, 3, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 6) + + def test_output_dir_path(self): + # commuter rail uses _ as delimiter + day_to_test = datetime(2024, 8, 7, 4) + expected_suffix = f'/Year={day_to_test.year}/Month={day_to_test.month}/Day={day_to_test.day}' + + cr_stop = output_dir_path('CR-Fairmount', '1', 'DB-2205-01', day_to_test) + assert cr_stop == f'daily-cr-data/CR-Fairmount_1_DB-2205-01{expected_suffix}' + + # no need to split rapid data by direction / line + rapid_stop = output_dir_path('Red', '0', '68', day_to_test) + assert rapid_stop == f'daily-rapid-data/68{expected_suffix}' + + # bus doesn't have underscore but data is split + bus_stop = output_dir_path('1', '0', '84', day_to_test) + assert bus_stop == f'daily-bus-data/1-0-84{expected_suffix}' + + def test_to_date_int(self): + assert to_dateint(date(2024, 8, 19)) == 20240819 + + From 52d1ee3b82c721dda01bda5c61016a55d3b54af7 Mon Sep 17 00:00:00 2001 From: JD Rudie Date: Mon, 19 Aug 2024 08:53:01 -0400 Subject: [PATCH 4/6] fixup: format --- src/tests/test_gtfs.py | 16 ++++++---------- src/tests/test_util.py | 19 ++++++++----------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/tests/test_gtfs.py b/src/tests/test_gtfs.py index 1dac940..128131c 100644 --- a/src/tests/test_gtfs.py +++ b/src/tests/test_gtfs.py @@ -32,7 +32,6 @@ def setUp(self): self.all_trips = pd.read_csv(DATA_DIR / "trips_mini.txt", dtype={"trip_short_name": str, "block_id": str}) - def test_add_gtfs_headways_batch(self): # expected stop info.... # 60063977,05:10:00,05:10:00,10003,5,,0,0,0,,, @@ -187,11 +186,10 @@ def test_add_gtfs_headways(self): post_df = gtfs.add_gtfs_headways(df, self.all_trips, self.stop_times) pd.testing.assert_frame_equal(post_df, expected_df) - # this is really more of an integration test... should we have an integration tests directory? def test_get_gtfs_archive_day_is_feed_returns_dir_of_day(self): # just a random day - + day_to_test: int = 20240807 expected_path: str = f"data/gtfs_archives/{str(day_to_test)}" @@ -225,7 +223,7 @@ def test_read_gtfs_date_exists_feed_is_read(self): assert result.service_date == day_to_test - orange_line_trips = result.trips_by_route_id('Orange') + orange_line_trips = result.trips_by_route_id("Orange") assert not orange_line_trips.empty # sanity check we have trips for each termini of the orange line @@ -233,14 +231,12 @@ def test_read_gtfs_date_exists_feed_is_read(self): assert "Oak Grove" in orange_line_trips["trip_headsign"].values # sanity check stops exist for the red line - assert not result.stop_times_by_route_id('Red').empty + assert not result.stop_times_by_route_id("Red").empty # red line has stop data for ashmont - assert '70094' in result.stop_times_by_route_id('Red')['stop_id'].values + assert "70094" in result.stop_times_by_route_id("Red")["stop_id"].values # the 1 bus has trips to harcard - assert not result.trips_by_route_id('1').empty - assert 'Harvard' in result.trips_by_route_id('1')['trip_headsign'].values + assert not result.trips_by_route_id("1").empty + assert "Harvard" in result.trips_by_route_id("1")["trip_headsign"].values shutil.rmtree(expected_path) - - diff --git a/src/tests/test_util.py b/src/tests/test_util.py index 023f70c..6b68961 100644 --- a/src/tests/test_util.py +++ b/src/tests/test_util.py @@ -2,6 +2,7 @@ from util import EASTERN_TIME, output_dir_path, service_date, to_dateint from unittest import TestCase + class TestUtil(TestCase): def test_service_date(self): assert service_date(datetime(2023, 12, 15, 3, 0, 0)) == date(2023, 12, 15) @@ -11,7 +12,6 @@ def test_service_date(self): assert service_date(datetime(2023, 12, 16, 0, 0, 0)) == date(2023, 12, 15) assert service_date(datetime(2023, 12, 16, 2, 59, 59)) == date(2023, 12, 15) - def test_localized_datetime(self): assert service_date(datetime(2023, 12, 15, 3, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) assert service_date(datetime(2023, 12, 15, 5, 45, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) @@ -20,7 +20,6 @@ def test_localized_datetime(self): assert service_date(datetime(2023, 12, 16, 0, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) assert service_date(datetime(2023, 12, 16, 2, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) - def test_edt_vs_est_datetimes(self): assert service_date(datetime(2023, 11, 5, 23, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) assert service_date(datetime(2023, 11, 6, 0, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) @@ -32,20 +31,18 @@ def test_edt_vs_est_datetimes(self): def test_output_dir_path(self): # commuter rail uses _ as delimiter day_to_test = datetime(2024, 8, 7, 4) - expected_suffix = f'/Year={day_to_test.year}/Month={day_to_test.month}/Day={day_to_test.day}' + expected_suffix = f"/Year={day_to_test.year}/Month={day_to_test.month}/Day={day_to_test.day}" - cr_stop = output_dir_path('CR-Fairmount', '1', 'DB-2205-01', day_to_test) - assert cr_stop == f'daily-cr-data/CR-Fairmount_1_DB-2205-01{expected_suffix}' + cr_stop = output_dir_path("CR-Fairmount", "1", "DB-2205-01", day_to_test) + assert cr_stop == f"daily-cr-data/CR-Fairmount_1_DB-2205-01{expected_suffix}" # no need to split rapid data by direction / line - rapid_stop = output_dir_path('Red', '0', '68', day_to_test) - assert rapid_stop == f'daily-rapid-data/68{expected_suffix}' + rapid_stop = output_dir_path("Red", "0", "68", day_to_test) + assert rapid_stop == f"daily-rapid-data/68{expected_suffix}" # bus doesn't have underscore but data is split - bus_stop = output_dir_path('1', '0', '84', day_to_test) - assert bus_stop == f'daily-bus-data/1-0-84{expected_suffix}' + bus_stop = output_dir_path("1", "0", "84", day_to_test) + assert bus_stop == f"daily-bus-data/1-0-84{expected_suffix}" def test_to_date_int(self): assert to_dateint(date(2024, 8, 19)) == 20240819 - - From e485d9bb107b5c7461903e4ba564222390c68bcd Mon Sep 17 00:00:00 2001 From: JD Rudie Date: Mon, 19 Aug 2024 08:55:39 -0400 Subject: [PATCH 5/6] fixup: flake --- src/tests/test_gtfs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/test_gtfs.py b/src/tests/test_gtfs.py index 128131c..dceada0 100644 --- a/src/tests/test_gtfs.py +++ b/src/tests/test_gtfs.py @@ -205,7 +205,7 @@ def test_get_gtfs_archive_day_not_feed_returns_dir_of_feed_containing_day(self): # from https://cdn.mbta.com/archive/archived_feeds.txt # 20240802,20240806,"Summer 2024, 2024-08-09T21:10:59+00:00, version D",https://cdn.mbtace.com/archive/20240802.zip,fix: Correct wrong-direction stop sequences etc in existing Ashmont-Mattapan shuttle definition; Add shuttle activation for 08/16-18 Mattapan shuttle; Replace Mattapan Line service during 08/16-18 suspension for track work; Add missing 25:00 info to shuttle activation; Fix formatting; Whoops! Change day_to_test: int = 20240804 - expected_path: str = f"data/gtfs_archives/20240802" + expected_path: str = f"data/gtfs_archives/{day_to_test}" result = gtfs.get_gtfs_archive(day_to_test) @@ -217,7 +217,7 @@ def test_get_gtfs_archive_day_not_feed_returns_dir_of_feed_containing_day(self): def test_read_gtfs_date_exists_feed_is_read(self): day_to_test = datetime.date(2024, 8, 7) - expected_path: str = f"data/gtfs_archives/20240807" + expected_path: str = f"data/gtfs_archives/{day_to_test}" result = gtfs.read_gtfs(day_to_test) From d7b8a9156adbc96b8a6db7d89a5ce84bf9f91cd1 Mon Sep 17 00:00:00 2001 From: JD Rudie Date: Mon, 19 Aug 2024 09:03:07 -0400 Subject: [PATCH 6/6] fixup: fix tests after format --- src/tests/test_gtfs.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tests/test_gtfs.py b/src/tests/test_gtfs.py index dceada0..eafb954 100644 --- a/src/tests/test_gtfs.py +++ b/src/tests/test_gtfs.py @@ -5,6 +5,7 @@ import pathlib import shutil from zoneinfo import ZoneInfo +from util import to_dateint import gtfs @@ -191,7 +192,7 @@ def test_get_gtfs_archive_day_is_feed_returns_dir_of_day(self): # just a random day day_to_test: int = 20240807 - expected_path: str = f"data/gtfs_archives/{str(day_to_test)}" + expected_path: str = f"data/gtfs_archives/{day_to_test}" result = gtfs.get_gtfs_archive(day_to_test) @@ -205,7 +206,7 @@ def test_get_gtfs_archive_day_not_feed_returns_dir_of_feed_containing_day(self): # from https://cdn.mbta.com/archive/archived_feeds.txt # 20240802,20240806,"Summer 2024, 2024-08-09T21:10:59+00:00, version D",https://cdn.mbtace.com/archive/20240802.zip,fix: Correct wrong-direction stop sequences etc in existing Ashmont-Mattapan shuttle definition; Add shuttle activation for 08/16-18 Mattapan shuttle; Replace Mattapan Line service during 08/16-18 suspension for track work; Add missing 25:00 info to shuttle activation; Fix formatting; Whoops! Change day_to_test: int = 20240804 - expected_path: str = f"data/gtfs_archives/{day_to_test}" + expected_path: str = "data/gtfs_archives/20240802" result = gtfs.get_gtfs_archive(day_to_test) @@ -217,7 +218,7 @@ def test_get_gtfs_archive_day_not_feed_returns_dir_of_feed_containing_day(self): def test_read_gtfs_date_exists_feed_is_read(self): day_to_test = datetime.date(2024, 8, 7) - expected_path: str = f"data/gtfs_archives/{day_to_test}" + expected_path: str = f"data/gtfs_archives/{to_dateint(day_to_test)}" result = gtfs.read_gtfs(day_to_test)