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: github.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:a674eb0a-7e3f-fb13-88a1-b7c17c9b81bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95AE:261A6D:3AEF621:513D957:6977DECD |
| html-safe-nonce | b42a62b5266d7942002d752f892912bafce535b8425570bddd1b5dcecb9c6c96 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUFFOjI2MUE2RDozQUVGNjIxOjUxM0Q5NTc6Njk3N0RFQ0QiLCJ2aXNpdG9yX2lkIjoiMTA5MzA3MDAxNjEyMDA4NjIyMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 70c34f4ba9943e2a2127c9d034afe53ec978f7ba881cbe34df0ba85f73c07fa7 |
| 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 | 8909f95e78dc1ccc1b9acf9d5c963c2515579e48d2898151cf571437facd1d7b |
| 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 | d6b13f6e4712dc1242cf12b5e75dec8b1bf3a9ab |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width