def test_full_update(self, product_fixture_elasticsearch_store):
        _id = uuid4()

        product = ProductFixture(_id=_id,
                                 timestamp=time(),
                                 name="jeans",
                                 description="cool jeans",
                                 quantity=5,
                                 price=Decimal("49.99"),
                                 enabled=False)
        product_fixture_elasticsearch_store.create(product)

        updated_name = "shirt"
        updated_description = "red t-shirt"
        updated_quantity = 10
        updated_price = Decimal("99.99")
        updated_enabled = True

        product.name = updated_name
        product.description = updated_description
        product.quantity = updated_quantity
        product.price = updated_price
        product.enabled = updated_enabled
        product.timestamp = time()
        product_fixture_elasticsearch_store.update(product)

        read_product = product_fixture_elasticsearch_store.read(_id)
        assert read_product.name == updated_name
        assert read_product.description == updated_description
        assert read_product.quantity == updated_quantity
        assert read_product.price == updated_price
        assert read_product.enabled == updated_enabled
    def test_fetch_multiple_save_updates_for_the_same_entity(self, cassandra_update_fetcher,
                                                             product_fixture_cassandra_store):
        _id = uuid.uuid4()
        timestamp = time()

        product_fixture = ProductFixture(_id=_id, timestamp=timestamp, name="The new MacBook Pro by Apple", quantity=10,
                                         description="it's amazing", price=Decimal("1999.99"), enabled=True)
        product_fixture_cassandra_store.create(product_fixture)

        product_fixture.price = Decimal("1499.99")
        product_fixture.timestamp = time()
        product_fixture_cassandra_store.update(product_fixture)

        product_fixture.description = "it' beyond amazing"
        product_fixture.enabled = False
        product_fixture.timestamp = time()
        product_fixture_cassandra_store.update(product_fixture)

        updates_iterator = cassandra_update_fetcher.fetch_updates(minimum_timestamp=timestamp)

        updates = []
        for update in updates_iterator:
            updates.append(update)

        assert len(updates) == 3

        fields = {}
        for update in updates:
            for field in update.fields:
                fields[field.name] = field.value

        assert fields["price"] == Decimal("1499.99")
        assert fields["description"] == "it' beyond amazing"
        assert fields["enabled"] is False
    def test_full_update(self, product_fixture_elasticsearch_store):
        _id = uuid4()

        product = ProductFixture(_id=_id, timestamp=time(), name="jeans", description="cool jeans", quantity=5,
                                 price=Decimal("49.99"), enabled=False)
        product_fixture_elasticsearch_store.create(product)

        updated_name = "shirt"
        updated_description = "red t-shirt"
        updated_quantity = 10
        updated_price = Decimal("99.99")
        updated_enabled = True

        product.name = updated_name
        product.description = updated_description
        product.quantity = updated_quantity
        product.price = updated_price
        product.enabled = updated_enabled
        product.timestamp = time()
        product_fixture_elasticsearch_store.update(product)

        read_product = product_fixture_elasticsearch_store.read(_id)
        assert read_product.name == updated_name
        assert read_product.description == updated_description
        assert read_product.quantity == updated_quantity
        assert read_product.price == updated_price
        assert read_product.enabled == updated_enabled
Example #4
0
    def test_fetch_multiple_save_updates_for_the_same_entity(
            self, cassandra_update_fetcher, product_fixture_cassandra_store):
        _id = uuid.uuid4()
        timestamp = time()

        product_fixture = ProductFixture(_id=_id,
                                         timestamp=timestamp,
                                         name="The new MacBook Pro by Apple",
                                         quantity=10,
                                         description="it's amazing",
                                         price=Decimal("1999.99"),
                                         enabled=True)
        product_fixture_cassandra_store.create(product_fixture)

        product_fixture.price = Decimal("1499.99")
        product_fixture.timestamp = time()
        product_fixture_cassandra_store.update(product_fixture)

        product_fixture.description = "it' beyond amazing"
        product_fixture.enabled = False
        product_fixture.timestamp = time()
        product_fixture_cassandra_store.update(product_fixture)

        updates_iterator = cassandra_update_fetcher.fetch_updates(
            minimum_timestamp=timestamp)

        updates = []
        for update in updates_iterator:
            updates.append(update)

        assert len(updates) == 3

        fields = {}
        for update in updates:
            for field in update.fields:
                fields[field.name] = field.value

        assert fields["price"] == Decimal("1499.99")
        assert fields["description"] == "it' beyond amazing"
        assert fields["enabled"] is False