<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by proxyroot on Medium]]></title>
        <description><![CDATA[Stories by proxyroot on Medium]]></description>
        <link>https://medium.com/@proxyroot?source=rss-2ae16572c1c0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by proxyroot on Medium</title>
            <link>https://medium.com/@proxyroot?source=rss-2ae16572c1c0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 20:31:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@proxyroot/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[drongo: the moto for Google Cloud]]></title>
            <link>https://medium.com/@proxyroot/drongo-the-moto-for-google-cloud-570b485382da?source=rss-2ae16572c1c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/570b485382da</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[motos]]></category>
            <category><![CDATA[pytest]]></category>
            <dc:creator><![CDATA[proxyroot]]></dc:creator>
            <pubDate>Fri, 31 Jul 2026 01:15:50 GMT</pubDate>
            <atom:updated>2026-07-31T01:15:50.606Z</atom:updated>
            <content:encoded><![CDATA[<h3>Your GCP tests deserve better than a pile of MagicMocks</h3><p>If you write Python against AWS, you already know how this is supposed to feel. You add @mock_aws, you call boto3 exactly the way production does, and you assert on what actually happened. <a href="https://github.com/getmoto/moto">moto</a> has made that the default for a decade.</p><p>If you write Python against Google Cloud, you know it does not feel like that at all.</p><p>drongo is an in-memory, in-process fake of GCP service APIs. One decorator, no network, no Docker, no emulator, no credentials:</p><pre>pip install drongo</pre><pre>from drongo import mock_gcp<br><br>@mock_gcp<br>def test_upload_download():<br>    from google.cloud import storage<br><br>    client = storage.Client(project=&quot;my-project&quot;)<br>    bucket = client.create_bucket(&quot;my-bucket&quot;)<br>    <br>    bucket.blob(&quot;hello.txt&quot;).upload_from_string(&quot;hello drongo&quot;)<br>    <br>    assert bucket.blob(&quot;hello.txt&quot;).download_as_text() == &quot;hello drongo&quot;<br>    assert [b.name for b in client.list_blobs(&quot;my-bucket&quot;)] == [&quot;hello.txt&quot;]</pre><p>That is the whole setup. Below is why it matters, with numbers rather than adjectives.</p><h3>What exists today, and where it hurts</h3><p>There are four ways teams test GCP code right now. Each one breaks somewhere.</p><p><strong>1. Official Google emulators.</strong> These are real and good, but they cover only a handful of services: Pub/Sub, Firestore, Datastore, Bigtable and Spanner. That is it. There is no official emulator for Cloud Storage, Secret Manager, BigQuery, Cloud Tasks, Cloud Run, KMS, Scheduler, IAM, Cloud Logging, Cloud Functions or Memorystore. The ones that do exist need the gcloud SDK and a JVM, or a Docker image, plus a process to start, a port to manage, and an env var to set before your client is constructed.</p><p><strong>2. Third-party emulators.</strong> fsouza/fake-gcs-server covers Storage. goccy/bigquery-emulator covers BigQuery. Both are excellent, both are written in Go, and both are one container each. A service that touches Storage, BigQuery and Pub/Sub needs three containers from three maintainers with three different fidelity levels and three ways to reset state between tests.</p><p><strong>3. Hand-rolled </strong><strong>unittest.mock.</strong> Free, instant, and the most common choice by far. It is also the one that quietly stops testing your code, for reasons I will demonstrate below.</p><p><strong>4. Hitting real GCP.</strong> Slow, costs money, needs credentials in CI, and cannot run on a plane.</p><p>The gap is structural: <strong>AWS has one uniform HTTP API that a single interception layer can fake. GCP is gRPC-first for many services, REST for others.</strong> That is precisely why a moto equivalent never appeared, and it is the problem drongo solves.</p><pre>|                                     | Coverage            | Needs                   | Speed            |<br>|-------------------------------------|---------------------|-------------------------|------------------|<br>| Google emulators                    | 5 services          | gcloud + JVM, or Docker | Seconds to start |<br>| fake-gcs-server / bigquery-emulator | 1 service each      | Docker, one per service | Seconds to start |<br>| unittest.mock                       | Anything, shallowly | Nothing                 | Instant          |<br>| Real GCP                            | Everything          | Credentials, money      | Seconds per call |<br>| drongo                              | 15 services         | Nothing                 | Milliseconds     |</pre><p>drongo handles the transport problem behind the scenes: HTTP services are intercepted, gRPC-first services get an in-process emulator or a forced-REST transport. Your code keeps using its normal client with its normal transport, and never knows.</p><h3>The real code</h3><p>Everything below tests this module. It is deliberately ordinary: read a key from Secret Manager, pull a CSV from Cloud Storage, load it into BigQuery, announce it on Pub/Sub. Four services, which is what makes it realistic.</p><pre># app/pipeline.py<br>&quot;&quot;&quot;Production code. Nothing here knows it will ever be tested.&quot;&quot;&quot;<br><br>from __future__ import annotations<br>import csv<br>import io<br>from google.cloud import bigquery, pubsub_v1, secretmanager, storage<br>PROJECT = &quot;shop&quot;<br>TOPIC = f&quot;projects/{PROJECT}/topics/ingest-complete&quot;<br><br>def ingest_orders(bucket: str, path: str) -&gt; int:<br>    &quot;&quot;&quot;Load a CSV of orders from GCS into BigQuery, then announce it.&quot;&quot;&quot;<br>    secrets = secretmanager.SecretManagerServiceClient()<br>    api_key = secrets.access_secret_version(<br>        request={&quot;name&quot;: f&quot;projects/{PROJECT}/secrets/feed-key/versions/latest&quot;}<br>    ).payload.data.decode()<br>    gcs = storage.Client(project=PROJECT)<br>    raw = gcs.bucket(bucket).blob(path).download_as_text()<br>    rows = [<br>        {<br>            &quot;order_id&quot;: r[&quot;order_id&quot;],<br>            &quot;amount&quot;: float(r[&quot;amount&quot;]),<br>            &quot;region&quot;: r[&quot;region&quot;],<br>        }<br>        for r in csv.DictReader(io.StringIO(raw))<br>        if float(r[&quot;amount&quot;]) &gt; 0<br>    ]<br>    bq = bigquery.Client(project=PROJECT)<br>    errors = bq.insert_rows_json(f&quot;{PROJECT}.analytics.orders&quot;, rows)<br>    if errors:<br>        raise RuntimeError(f&quot;BigQuery insert failed: {errors}&quot;)<br>    publisher = pubsub_v1.PublisherClient()<br>    publisher.publish(<br>        TOPIC, f&quot;{len(rows)}&quot;.encode(), source=path, key_id=api_key[:4]<br>    ).result()<br>    return len(rows)</pre><p>Note what production code does <em>not</em> contain: no dependency injection seam, no client factory parameter, no if testing: branch. Nothing was bent to make it testable.</p><h3>The test code, three ways</h3><h3>Way 1: MagicMock</h3><pre># tests/test_pipeline_mocks.py<br>from unittest.mock import MagicMock, patch<br><br>from app.pipeline import ingest_orders<br>CSV = &quot;order_id,amount,region\na1,10.5,us\na2,0,us\na3,7.25,eu\n&quot;<br><br>@patch(&quot;app.pipeline.pubsub_v1.PublisherClient&quot;)<br>@patch(&quot;app.pipeline.bigquery.Client&quot;)<br>@patch(&quot;app.pipeline.storage.Client&quot;)<br>@patch(&quot;app.pipeline.secretmanager.SecretManagerServiceClient&quot;)<br>def test_ingest_orders(mock_secrets, mock_storage, mock_bq, mock_pubsub):<br>    # Secret Manager: access_secret_version().payload.data.decode()<br>    secret_version = MagicMock()<br>    secret_version.payload.data = b&quot;key-abcdef&quot;<br>    mock_secrets.return_value.access_secret_version.return_value = secret_version<br>    # Storage: bucket().blob().download_as_text()<br>    blob = MagicMock()<br>    blob.download_as_text.return_value = CSV<br>    bucket = MagicMock()<br>    bucket.blob.return_value = blob<br>    mock_storage.return_value.bucket.return_value = bucket<br>    # BigQuery: insert_rows_json() -&gt; [] means success<br>    mock_bq.return_value.insert_rows_json.return_value = []<br>    # Pub/Sub: publish().result()<br>    future = MagicMock()<br>    future.result.return_value = &quot;msg-1&quot;<br>    mock_pubsub.return_value.publish.return_value = future<br>    count = ingest_orders(&quot;dropzone&quot;, &quot;orders/2026-07-30.csv&quot;)<br>    assert count == 2<br>    # Every assertion is against the mock&#39;s call log, not real behaviour.<br>    table, rows = mock_bq.return_value.insert_rows_json.call_args[0]<br>    assert table == &quot;shop.analytics.orders&quot;<br>    assert rows == [<br>        {&quot;order_id&quot;: &quot;a1&quot;, &quot;amount&quot;: 10.5, &quot;region&quot;: &quot;us&quot;},<br>        {&quot;order_id&quot;: &quot;a3&quot;, &quot;amount&quot;: 7.25, &quot;region&quot;: &quot;eu&quot;},<br>    ]</pre><p>Read those setup lines again. mock_storage.return_value.bucket.return_value.blob.return_value.download_as_text.return_value is not a description of Cloud Storage. It is a transcription of the exact call chain inside ingest_orders. <strong>The test now contains a copy of the implementation.</strong> Hold that thought.</p><h3>Way 2: drongo</h3><pre># tests/test_pipeline_drongo.py<br>from drongo import mock_gcp<br><br>from app.pipeline import ingest_orders<br>CSV = &quot;order_id,amount,region\na1,10.5,us\na2,0,us\na3,7.25,eu\n&quot;<br><br>@mock_gcp<br>def test_ingest_orders():<br>    from google.cloud import bigquery, pubsub_v1, secretmanager, storage<br>    # Arrange: build the world the way production would.<br>    secrets = secretmanager.SecretManagerServiceClient()<br>    secrets.create_secret(<br>        request={<br>            &quot;parent&quot;: &quot;projects/shop&quot;,<br>            &quot;secret_id&quot;: &quot;feed-key&quot;,<br>            &quot;secret&quot;: {&quot;replication&quot;: {&quot;automatic&quot;: {}}},<br>        }<br>    )<br>    secrets.add_secret_version(<br>        request={<br>            &quot;parent&quot;: &quot;projects/shop/secrets/feed-key&quot;,<br>            &quot;payload&quot;: {&quot;data&quot;: b&quot;key-abcdef&quot;},<br>        }<br>    )<br>    gcs = storage.Client(project=&quot;shop&quot;)<br>    gcs.create_bucket(&quot;dropzone&quot;)<br>    gcs.bucket(&quot;dropzone&quot;).blob(&quot;orders/2026-07-30.csv&quot;).upload_from_string(CSV)<br>    bq = bigquery.Client(project=&quot;shop&quot;)<br>    bq.create_dataset(&quot;shop.analytics&quot;)<br>    bq.create_table(<br>        bigquery.Table(<br>            &quot;shop.analytics.orders&quot;,<br>            schema=[<br>                bigquery.SchemaField(&quot;order_id&quot;, &quot;STRING&quot;),<br>                bigquery.SchemaField(&quot;amount&quot;, &quot;FLOAT&quot;),<br>                bigquery.SchemaField(&quot;region&quot;, &quot;STRING&quot;),<br>            ],<br>        )<br>    )<br>    publisher = pubsub_v1.PublisherClient()<br>    subscriber = pubsub_v1.SubscriberClient()<br>    publisher.create_topic(request={&quot;name&quot;: &quot;projects/shop/topics/ingest-complete&quot;})<br>    subscriber.create_subscription(<br>        request={<br>            &quot;name&quot;: &quot;projects/shop/subscriptions/audit&quot;,<br>            &quot;topic&quot;: &quot;projects/shop/topics/ingest-complete&quot;,<br>        }<br>    )<br>    # Act<br>    count = ingest_orders(&quot;dropzone&quot;, &quot;orders/2026-07-30.csv&quot;)<br>    # Assert: read the data back, exactly as another service would.<br>    assert count == 2<br>    stored = sorted(<br>        (dict(r) for r in bq.list_rows(&quot;shop.analytics.orders&quot;)),<br>        key=lambda r: r[&quot;order_id&quot;],<br>    )<br>    assert stored == [<br>        {&quot;order_id&quot;: &quot;a1&quot;, &quot;amount&quot;: 10.5, &quot;region&quot;: &quot;us&quot;},<br>        {&quot;order_id&quot;: &quot;a3&quot;, &quot;amount&quot;: 7.25, &quot;region&quot;: &quot;eu&quot;},<br>    ]<br>    pulled = subscriber.pull(<br>        request={<br>            &quot;subscription&quot;: &quot;projects/shop/subscriptions/audit&quot;,<br>            &quot;max_messages&quot;: 10,<br>        }<br>    )<br>    (msg,) = [m.message for m in pulled.received_messages]<br>    assert msg.data == b&quot;2&quot;<br>    assert msg.attributes[&quot;source&quot;] == &quot;orders/2026-07-30.csv&quot;</pre><p>Every line is an API call you could paste into production. There is not one return_value in it.</p><h3>Let me be honest about “less code”</h3><p>Here is where most tool announcements would claim a big line-count win. I measured it instead, and the first result did not go my way.</p><p>For that single test: <strong>MagicMock 36 lines, drongo 61 lines.</strong> Extended to four shallow tests sharing a helper: <strong>45 lines versus 74</strong>, and a marginal cost of <strong>4.8 versus 5.5 lines per additional test.</strong></p><p>So if your bar is “assert that a method was called”, MagicMock is genuinely less code, and drongo is not going to beat it. I would rather say that plainly than cherry-pick.</p><p>The comparison changes completely once you ask for tests that are actually worth having. To write the three tests in the next section with mocks, you cannot use MagicMock, because they require <em>state</em>: a bucket that remembers what you uploaded, a table that accumulates rows, a 404 when an object is missing. You have to hand-write stateful fakes. So I did: FakeBlob, FakeBucket, FakeStorageClient, FakeTable, FakeBQClient, FakeFuture, FakeMessage, FakePublisher, FakeSecretClient, and a reset().</p><pre>| Same three tests   | Fake infrastructure | Test code | Total     |<br>|--------------------|---------------------|-----------|-----------|<br>| Hand-written fakes | 107 lines           | 45 lines  | 152 lines |<br>| drongo             | 0 lines             | 58 lines  | 58 lines  |</pre><p><strong>61% less code, and the 107-line file you delete is the one that rots.</strong> Those fakes are a second, worse implementation of Google Cloud that you now own, and they drift from the real API silently, because nothing tells you when they are wrong.</p><p>That is the honest shape of the win. drongo is not fewer lines than a shallow mock. It is dramatically fewer lines than a test suite that means something.</p><h3>Speed</h3><p>All figures from a full run on an M-series laptop, no Docker, no network.</p><pre>| What                                     | Tests | Wall clock |<br>|------------------------------------------|-------|------------|<br>| drongo&#39;s own suite, 15 services          | 187   | 2.7s       |<br>| Cloud Storage suite                      | 26    | 0.45s      |<br>| A single Storage test                    | 1     | 0.32s      |<br>| Pub/Sub suite (in-process gRPC emulator) | 15    | 0.59s      |<br>| pytest process floor, no tests           | 0     | 0.03s      |</pre><p>Look at rows two and three. <strong>Twenty-six Storage tests cost the same wall clock as one.</strong> Nearly all of that 0.3s is Python importing google-cloud-storage, which you pay once per process. The marginal cost of one more drongo test is roughly <strong>5 milliseconds</strong>.</p><p>That is the number that changes behaviour. At 5ms, there is no reason not to test the empty-file case, the malformed-row case, and the duplicate-delivery case. Compare with a Docker emulator, where container startup alone is seconds before a single assertion runs, and the entire incentive is to write one fat test instead of twelve sharp ones.</p><h3>The part mocks cannot do</h3><p>This is the real argument, and it is not about speed.</p><h3>Experiment 1: a refactor that changes nothing</h3><p>Take the production code and make a behaviour-preserving change. bucket().blob() becomes get_bucket().get_blob(). Same result, arguably better, since it now fails loudly on a missing bucket:</p><pre>- raw = gcs.bucket(bucket).blob(path).download_as_text()<br>+ raw = gcs.get_bucket(bucket).get_blob(path).download_as_text()</pre><p>Result:</p><pre>tests/test_pipeline_drongo.py .                                     [ 50%]<br>tests/test_pipeline_mocks.py F                                      [100%]</pre><pre>E   TypeError: initial_value must be str or None, not MagicMock</pre><p><strong>The drongo test passes. The mock test fails, with an error that names neither the bucket nor the blob.</strong> Nothing broke. The mock was configured for bucket, the code called get_bucket, and MagicMock cheerfully invented a new attribute returning another MagicMock, which flowed downstream until io.StringIO choked on it.</p><p>This is the tax, and every team paying it has normalised it: <strong>your tests fail when you refactor, and pass when you break things.</strong> They are coupled to how the code is written, not what it does. drongo tests are coupled to observable behaviour, so they survive refactors and object to bugs.</p><h3>Experiment 2: tests that have nowhere to live</h3><pre># tests/test_state.py<br>import pytest<br>from google.api_core import exceptions as gexc<br><br>from app.pipeline import ingest_orders<br>pytestmark = pytest.mark.usefixtures(&quot;drongo&quot;)<br><br>def _row_count() -&gt; int:<br>    from google.cloud import bigquery<br>    client = bigquery.Client(project=&quot;shop&quot;)<br>    return len(list(client.list_rows(&quot;shop.analytics.orders&quot;)))<br><br># `_world()` is the same arrange block as the `gcp` fixture shown later:<br># it creates the secret, bucket, dataset + table and topic.<br><br>def test_reingesting_the_same_file_duplicates_rows():<br>    &quot;&quot;&quot;Real state makes a real bug visible: this pipeline is not idempotent.&quot;&quot;&quot;<br>    _world()<br>    ingest_orders(&quot;dropzone&quot;, &quot;orders/day.csv&quot;)<br>    assert _row_count() == 2<br>    ingest_orders(&quot;dropzone&quot;, &quot;orders/day.csv&quot;)<br>    assert _row_count() == 4  # a mock has no table, so it cannot see this<br><br>def test_missing_object_raises_not_found():<br>    &quot;&quot;&quot;A MagicMock returns canned data for any path. Real storage 404s.&quot;&quot;&quot;<br>    _world(upload=False)<br>    with pytest.raises(gexc.NotFound):<br>        ingest_orders(&quot;dropzone&quot;, &quot;orders/day.csv&quot;)<br><br>def test_empty_file_publishes_nothing_useful():<br>    _world(csv_body=&quot;order_id,amount,region\n&quot;)<br>    assert ingest_orders(&quot;dropzone&quot;, &quot;orders/day.csv&quot;) == 0<br>    assert _row_count() == 0</pre><p>The first test documents a genuine production bug: re-running the pipeline double-inserts every row. <strong>You cannot write that test with </strong><strong>MagicMock, at any length</strong>, because asserting &quot;the table contains four rows&quot; requires a table. The mock has a call log instead, and a call log cannot tell you that your data is now wrong.</p><p>These three tests run in <strong>0.63 seconds</strong>.</p><h3>Reusable fixtures, and data you did not hand-write</h3><p>Since drongo state lives in ordinary in-memory backends, the arrange step is just a pytest fixture. Write the world once, share it across the suite:</p><pre># tests/conftest.py<br>import pytest<br><br>from drongo import seed<br>PROJECT = &quot;shop&quot;<br>ORDERS = f&quot;{PROJECT}.analytics.orders&quot;<br>TOPIC = f&quot;projects/{PROJECT}/topics/ingest-complete&quot;<br><br>@pytest.fixture(autouse=True)<br>def _deterministic():<br>    &quot;&quot;&quot;Same fake data on every run, and on every developer&#39;s machine.&quot;&quot;&quot;<br>    seed.seed(1234)<br><br>@pytest.fixture<br>def gcp(drongo):<br>    &quot;&quot;&quot;A ready-to-use GCP world: bucket, dataset + table, topic + subscription, secret.<br>    Depends on the `drongo` fixture, which is auto-registered on install,<br>    so the mock scope is already active here.<br>    &quot;&quot;&quot;<br>    from google.cloud import bigquery, pubsub_v1, secretmanager, storage<br>    sm = secretmanager.SecretManagerServiceClient()<br>    sm.create_secret(<br>        request={<br>            &quot;parent&quot;: f&quot;projects/{PROJECT}&quot;,<br>            &quot;secret_id&quot;: &quot;feed-key&quot;,<br>            &quot;secret&quot;: {&quot;replication&quot;: {&quot;automatic&quot;: {}}},<br>        }<br>    )<br>    sm.add_secret_version(<br>        request={<br>            &quot;parent&quot;: f&quot;projects/{PROJECT}/secrets/feed-key&quot;,<br>            &quot;payload&quot;: {&quot;data&quot;: b&quot;key-abcdef&quot;},<br>        }<br>    )<br>    gcs = storage.Client(project=PROJECT)<br>    gcs.create_bucket(&quot;dropzone&quot;)<br>    bq = bigquery.Client(project=PROJECT)<br>    bq.create_dataset(f&quot;{PROJECT}.analytics&quot;)<br>    bq.create_table(<br>        bigquery.Table(<br>            ORDERS,<br>            schema=[<br>                bigquery.SchemaField(&quot;order_id&quot;, &quot;STRING&quot;),<br>                bigquery.SchemaField(&quot;amount&quot;, &quot;FLOAT&quot;),<br>                bigquery.SchemaField(&quot;region&quot;, &quot;STRING&quot;),<br>                bigquery.SchemaField(&quot;order_date&quot;, &quot;DATE&quot;),<br>                bigquery.SchemaField(&quot;paid&quot;, &quot;BOOLEAN&quot;),<br>            ],<br>        )<br>    )<br>    pub = pubsub_v1.PublisherClient()<br>    pub.create_topic(request={&quot;name&quot;: TOPIC})<br>    sub = pubsub_v1.SubscriberClient()<br>    sub.create_subscription(<br>        request={&quot;name&quot;: f&quot;projects/{PROJECT}/subscriptions/audit&quot;, &quot;topic&quot;: TOPIC}<br>    )<br>    return type(&quot;World&quot;, (), {&quot;gcs&quot;: gcs, &quot;bq&quot;: bq, &quot;pub&quot;: pub, &quot;sub&quot;: sub})()</pre><p>There is no teardown, because the scope resets backends between tests automatically.</p><p>Now the payoff. drongo.seed drives the <em>real</em> clients inside the mock scope using <a href="https://faker.readthedocs.io/">Faker</a>, so generated data lands in the backends exactly like your code&#39;s own writes. It reads the table schema and generates a correctly typed value per column:</p><pre># tests/test_seeded.py<br>from drongo import seed<br><br>from tests.conftest import ORDERS, TOPIC<br><br>def test_report_over_realistic_volume(gcp):<br>    &quot;&quot;&quot;5,000 rows of schema-correct fake data in one call.&quot;&quot;&quot;<br>    rows = seed.bigquery_rows(gcp.bq, ORDERS, count=5000, overrides={&quot;region&quot;: &quot;us&quot;})<br>    assert len(rows) == 5000<br>    assert len(list(gcp.bq.list_rows(ORDERS))) == 5000<br>    # Faker matched the declared BigQuery types, per column.<br>    assert isinstance(rows[0][&quot;amount&quot;], float)<br>    assert isinstance(rows[0][&quot;paid&quot;], bool)<br>    assert rows[0][&quot;region&quot;] == &quot;us&quot;  # pinned, so assertions stay stable<br><br>def test_seeded_blobs_and_messages(gcp):<br>    names = seed.storage_blobs(gcp.gcs, &quot;dropzone&quot;, count=50, prefix=&quot;invoice&quot;)<br>    ids = seed.pubsub_messages(gcp.pub, TOPIC, count=100)<br>    assert len(names) == 50<br>    assert names[0] == &quot;invoice-0.txt&quot;<br>    assert len(ids) == 100</pre><p>Five thousand schema-correct BigQuery rows in <strong>one line and 0.21 seconds</strong>. overrides pins the columns your assertions depend on, so your data is realistic where you want variety and fixed where you want determinism, and seed.seed(1234) in the autouse fixture means the same bytes on every machine and every CI run.</p><p>That combination is the practical answer to “less hassle”: no fixture JSON files, no committed CSV samples, no 200-line _make_rows() helper.</p><h3>Two more things worth knowing</h3><p><strong>Executable handlers.</strong> By default drongo mocks the API surface. Opt in, and it will actually run your Python when a job runs, a task dispatches, or a message publishes, so one test exercises the whole producer to consumer path in-process:</p><pre>from drongo import mock_gcp, pubsub<br><br>@mock_gcp<br>def test_publish_pushes_to_subscriber():<br>    from google.cloud import pubsub_v1<br>    seen = []<br>    @pubsub.subscription_handler(&quot;projects/p/subscriptions/worker&quot;)<br>    def on_message(message):<br>        seen.append(message.data)  # returning acks; raising redelivers<br>    publisher = pubsub_v1.PublisherClient()<br>    subscriber = pubsub_v1.SubscriberClient()<br>    publisher.create_topic(request={&quot;name&quot;: &quot;projects/p/topics/orders&quot;})<br>    subscriber.create_subscription(<br>        request={<br>            &quot;name&quot;: &quot;projects/p/subscriptions/worker&quot;,<br>            &quot;topic&quot;: &quot;projects/p/topics/orders&quot;,<br>        }<br>    )<br>    publisher.publish(&quot;projects/p/topics/orders&quot;, b&#39;{&quot;id&quot;: 1}&#39;).result()<br>    assert seen == [b&#39;{&quot;id&quot;: 1}&#39;]</pre><p>moto shells out to Docker to run Lambda. drongo runs your callable in-process, which is why it stays in milliseconds.</p><p><strong>A real HTTP server, for non-Python SDKs.</strong> drongo server --port 9090 replays the same route tables over a socket, so a Go, Node or Java SDK can point at it with the usual emulator env var:</p><pre>drongo server --port 9090<br>export STORAGE_EMULATOR_HOST=http://localhost:9090</pre><h3>Where drongo is not there yet</h3><p>An announcement that only lists strengths is marketing. The honest boundaries:</p><ul><li><strong>BigQuery has no SQL engine.</strong> Datasets, tables, streaming inserts and reading rows work. client.query(&quot;SELECT ...&quot;) does not. If your logic lives in SQL, drongo tests the plumbing around it, not the query.</li><li><strong>The fidelity is API-shaped, not billing-shaped.</strong> No quotas, no IAM permission denials, no eventual consistency. Tests that need those still belong against real GCP.</li><li><strong>Validation is not exhaustive.</strong> I checked this while writing the article: inserting a column absent from a BigQuery table schema is currently accepted, where real BigQuery rejects it. A strict MagicMock assertion would have caught that one. Depth is being added service by service, and gaps are tracked openly.</li><li><strong>15 services, not 150.</strong> Storage, Secret Manager, Pub/Sub, BigQuery, Cloud Tasks, Cloud Run Jobs, Resource Manager, Firestore, Datastore, IAM, Cloud Logging, KMS, Scheduler, Cloud Functions and Memorystore are in. Spanner, Bigtable and Compute are on the roadmap.</li></ul><p>Adding a service is deliberately mechanical, the same models.py / responses.py / urls.py trio moto uses. If the service you need is missing, that is a very good first pull request.</p><h3>Try it</h3><pre>pip install drongo</pre><pre>from drongo import mock_gcp<br><br><br>@mock_gcp<br>def test_it():<br>    from google.cloud import storage<br>    storage.Client(project=&quot;p&quot;).create_bucket(&quot;b&quot;)</pre><ul><li><strong>Docs:</strong> <a href="https://drongo.proxyroot.com/">drongo.proxyroot.com</a></li><li><strong>Source:</strong> <a href="https://github.com/proxyroot/drongo">github.com/proxyroot/drongo</a></li><li><strong>License:</strong> Apache 2.0, the same as moto</li></ul><p>The name, since someone will ask: boto is the Amazon river dolphin, and moto mocks boto. The fork-tailed drongo is a bird that mimics other animals&#39; alarm calls to make them drop their food. Convincing mimicry is exactly the job.</p><p>If you have been putting up with a 400-line fakes.py and a test suite that fails whenever you rename a method, give it twenty minutes. Star the repo if it saves you an afternoon, and open an issue for the service you need next.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=570b485382da" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>