def test_serialize_string_as_datetime_if_column_type_is_datetime(self,
            cassandra_document_store, cassandra_fixture_keyspace, product_fixture_table):
        publish_date = datetime.utcnow()

        document = Document()
        document.identifier = Identifier(cassandra_fixture_keyspace, product_fixture_table, uuid4())
        document.timestamp = time()
        document.add_field("publish_date", str(publish_date))

        cassandra_document_store.create(document)
        read_document = cassandra_document_store.read(document.identifier)
        assert DateTimeUtil.are_equal_by_less_than(read_document.get_field_value("publish_date"), publish_date, 0.001)
コード例 #2
0
    def test_serialize_string_as_datetime_if_column_type_is_datetime(
            self, cassandra_document_store, cassandra_fixture_keyspace,
            product_fixture_table):
        publish_date = datetime.utcnow()

        document = Document()
        document.identifier = Identifier(cassandra_fixture_keyspace,
                                         product_fixture_table, uuid4())
        document.timestamp = time()
        document.add_field("publish_date", str(publish_date))

        cassandra_document_store.create(document)
        read_document = cassandra_document_store.read(document.identifier)
        assert DateTimeUtil.are_equal_by_less_than(
            read_document.get_field_value("publish_date"), publish_date, 0.001)
    def test_read(self, cassandra_document_store, product,
                  product_fixture_cassandra_store, cassandra_fixture_keyspace, product_fixture_table):

        product_fixture_cassandra_store.create(product)

        identifier = Identifier(cassandra_fixture_keyspace, product_fixture_table, product.key)
        document = cassandra_document_store.read(identifier)

        assert TimestampUtil.are_equal_by_less_than(product.timestamp, document.timestamp, 0.001)
        assert document.identifier == identifier
        assert document.get_field_value("name") == product.name
        assert document.get_field_value("description") == product.description
        assert document.get_field_value("price") == product.price
        assert document.get_field_value("quantity") == product.quantity
        assert document.get_field_value("enabled") == product.enabled
        assert document.get_field_value("external_id") == product.external_id
        assert DateTimeUtil.are_equal_by_less_than(
            document.get_field_value("publish_date"), product.publish_date, 0.001)
コード例 #4
0
    def test_read(self, cassandra_document_store, product,
                  product_fixture_cassandra_store, cassandra_fixture_keyspace,
                  product_fixture_table):

        product_fixture_cassandra_store.create(product)

        identifier = Identifier(cassandra_fixture_keyspace,
                                product_fixture_table, product.key)
        document = cassandra_document_store.read(identifier)

        assert TimestampUtil.are_equal_by_less_than(product.timestamp,
                                                    document.timestamp, 0.001)
        assert document.identifier == identifier
        assert document.get_field_value("name") == product.name
        assert document.get_field_value("description") == product.description
        assert document.get_field_value("price") == product.price
        assert document.get_field_value("quantity") == product.quantity
        assert document.get_field_value("enabled") == product.enabled
        assert document.get_field_value("external_id") == product.external_id
        assert DateTimeUtil.are_equal_by_less_than(
            document.get_field_value("publish_date"), product.publish_date,
            0.001)
コード例 #5
0
 def _deep_equals(self, other):
     return self.id == other.id and self.name == other.name and \
         self.quantity == other.quantity and self.description == other.description and \
         self.price == other.price and self.enabled == other.enabled and \
         self.external_id == other.external_id and \
         DateTimeUtil.are_equal_by_less_than(self.publish_date, other.publish_date, 0.001)
コード例 #6
0
 def _deep_equals(self, other):
     return self.id == other.id and self.name == other.name and \
         self.quantity == other.quantity and self.description == other.description and \
         self.price == other.price and self.enabled == other.enabled and \
         self.external_id == other.external_id and \
         DateTimeUtil.are_equal_by_less_than(self.publish_date, other.publish_date, 0.001)