Title: what's the purpose of line_allocated_event for redis? · Issue #70 · cosmicpython/code · GitHub
Open Graph Title: what's the purpose of line_allocated_event for redis? · Issue #70 · cosmicpython/code
X Title: what's the purpose of line_allocated_event for redis? · Issue #70 · cosmicpython/code
Description: Hello, thanks for all the resources you provided in the book, helping me tremendously to understand what a clean architecture could look like in python world. Just have a quick question about this line in end-to-end test: **subscription ...
Open Graph Description: Hello, thanks for all the resources you provided in the book, helping me tremendously to understand what a clean architecture could look like in python world. Just have a quick question about this ...
X Description: Hello, thanks for all the resources you provided in the book, helping me tremendously to understand what a clean architecture could look like in python world. Just have a quick question about this ...
Opengraph URL: https://github.com/cosmicpython/code/issues/70
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"what's the purpose of line_allocated_event for redis?","articleBody":"Hello, thanks for all the resources you provided in the book, helping me tremendously to understand what a clean architecture could look like in python world. Just have a quick question about this line in end-to-end test:\r\n\r\n **subscription = redis_client.subscribe_to(\"line_allocated\")**\r\n\r\nwhat's line_allocated channel needed for? I could see that the message is getting published to \"change_batch_quantity\" channel but we are subscribed to a different channel but somehow still able to read the messages that come from change_batch_quantity. I might be missing something easy to understand as i don't have a lot of experience with redis pubsub. I thought the channel names should have been same for them to exchange messages. Regardless of it, the tests pass so it seems like i'm missing something here. Thank you\r\n\r\n```\r\n@pytest.mark.usefixtures(\"postgres_db\")\r\n@pytest.mark.usefixtures(\"restart_api\")\r\n@pytest.mark.usefixtures(\"restart_redis_pubsub\")\r\ndef test_change_batch_quantity_leading_to_reallocation():\r\n # start with two batches and an order allocated to one of them\r\n orderid, sku = random_orderid(), random_sku()\r\n earlier_batch, later_batch = random_batchref(\"old\"), random_batchref(\"newer\")\r\n api_client.post_to_add_batch(earlier_batch, sku, qty=10, eta=\"2011-01-01\")\r\n api_client.post_to_add_batch(later_batch, sku, qty=10, eta=\"2011-01-02\")\r\n r = api_client.post_to_allocate(orderid, sku, 10)\r\n assert r.ok\r\n response = api_client.get_allocation(orderid)\r\n assert response.json()[0][\"batchref\"] == earlier_batch\r\n\r\n **subscription = redis_client.subscribe_to(\"line_allocated\")**\r\n\r\n # change quantity on allocated batch so it's less than our order\r\n redis_client.publish_message(\r\n \"change_batch_quantity\",\r\n {\"batchref\": earlier_batch, \"qty\": 5},\r\n )\r\n\r\n # wait until we see a message saying the order has been reallocated\r\n messages = []\r\n for attempt in Retrying(stop=stop_after_delay(3), reraise=True):\r\n with attempt:\r\n message = subscription.get_message(timeout=1)\r\n if message:\r\n messages.append(message)\r\n print(messages)\r\n data = json.loads(messages[-1][\"data\"])\r\n assert data[\"orderid\"] == orderid\r\n assert data[\"batchref\"] == later_batch\r\n```","author":{"url":"https://github.com/uguryiilmz","@type":"Person","name":"uguryiilmz"},"datePublished":"2023-05-12T19:44:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/70/code/issues/70"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5a1303e1-35c9-ae7d-f447-f74751bfe0ed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B92E:14F335:E766E32:12D1459B:69771F39 |
| html-safe-nonce | a2518e2b445bc0b7ae607156521cd240fac4e1e4d92f19f6a806318c7c7dd5a7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTJFOjE0RjMzNTpFNzY2RTMyOjEyRDE0NTlCOjY5NzcxRjM5IiwidmlzaXRvcl9pZCI6Ijg4OTc2MTM5OTA1ODY2ODcyODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4ee4528e66938939e35d0efb4c0039e932c6711a517cd8339ab4cfc404c0daf2 |
| hovercard-subject-tag | issue:1708122833 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cosmicpython/code/70/issue_layout |
| twitter:image | https://opengraph.githubassets.com/95aefec10f36cc674b45e0022cc1010eaadf3c5e9df9f59a2c8e35608bf65ae8/cosmicpython/code/issues/70 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/95aefec10f36cc674b45e0022cc1010eaadf3c5e9df9f59a2c8e35608bf65ae8/cosmicpython/code/issues/70 |
| og:image:alt | Hello, thanks for all the resources you provided in the book, helping me tremendously to understand what a clean architecture could look like in python world. Just have a quick question about this ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | uguryiilmz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09 |
| turbo-cache-control | no-preview |
| go-import | github.com/cosmicpython/code git https://github.com/cosmicpython/code.git |
| octolytics-dimension-user_id | 47350834 |
| octolytics-dimension-user_login | cosmicpython |
| octolytics-dimension-repository_id | 169221290 |
| octolytics-dimension-repository_nwo | cosmicpython/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 169221290 |
| octolytics-dimension-repository_network_root_nwo | cosmicpython/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f752335dbbea672610081196a1998e39aec5e14b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width