Exemple #1
0
    def test_dumps_and_loads(self):
        in_resource = IdentifiableBook(
            id=uuid.uuid4(),
            purchased_from=From.Ebay,
            title='Consider Phlebas',
            isbn='0-333-45430-8',
            num_pages=471,
            rrp=19.50,
            fiction=True,
            genre="sci-fi",
            authors=[Author(name="Iain M. Banks")],
            publisher=Publisher(name="Macmillan"),
        )

        data = msgpack_codec.dumps(in_resource)
        out_resource = msgpack_codec.loads(data)

        assert out_resource.id == in_resource.id
        assert out_resource.purchased_from == in_resource.purchased_from
        assert out_resource.title == in_resource.title
        assert out_resource.isbn == in_resource.isbn
        assert out_resource.num_pages == in_resource.num_pages
        assert out_resource.rrp == in_resource.rrp
        assert out_resource.fiction == in_resource.fiction
        assert out_resource.genre == in_resource.genre
        assert out_resource.authors[0].name == in_resource.authors[0].name
        assert out_resource.publisher.name == in_resource.publisher.name
    def test_dumps_and_loads(self):
        in_resource = IdentifiableBook(
            id=uuid.uuid4(),
            purchased_from=From.Ebay,
            title='Consider Phlebas',
            isbn='0-333-45430-8',
            num_pages=471,
            rrp=19.50,
            fiction=True,
            genre="sci-fi",
            authors=[Author(name="Iain M. Banks")],
            publisher=Publisher(name="Macmillan"),
        )

        data = msgpack_codec.dumps(in_resource)
        out_resource = msgpack_codec.loads(data)

        assert out_resource.id == in_resource.id
        assert out_resource.purchased_from == in_resource.purchased_from
        assert out_resource.title == in_resource.title
        assert out_resource.isbn == in_resource.isbn
        assert out_resource.num_pages == in_resource.num_pages
        assert out_resource.rrp == in_resource.rrp
        assert out_resource.fiction == in_resource.fiction
        assert out_resource.genre == in_resource.genre
        assert out_resource.authors[0].name == in_resource.authors[0].name
        assert out_resource.publisher.name == in_resource.publisher.name
Exemple #3
0
    def test_dumps_and_loads(self):
        in_resource = Book(
            title='Consider Phlebas',
            num_pages=471,
            rrp=19.50,
            fiction=True,
            genre="sci-fi",
            authors=[Author(name="Iain M. Banks")],
            publisher=Publisher(name="Macmillan"),
        )

        data = msgpack_codec.dumps(in_resource)
        out_resource = msgpack_codec.loads(data)

        self.assertEqual(out_resource.title, in_resource.title)
        self.assertEqual(out_resource.num_pages, in_resource.num_pages)
        self.assertEqual(out_resource.rrp, in_resource.rrp)
        self.assertEqual(out_resource.fiction, in_resource.fiction)
        self.assertEqual(out_resource.genre, in_resource.genre)
        self.assertEqual(out_resource.authors[0].name, in_resource.authors[0].name)
        self.assertEqual(out_resource.publisher.name, in_resource.publisher.name)