<s> from nose . tools import eq_ <EOL> from kitsune . sumo . tests import TestCase <EOL> from kitsune . sumo . urlresolvers import reverse <EOL> from kitsune . products import api <EOL> from kitsune . products . tests import ProductFactory , TopicFactory <EOL> class TestProductSerializerSerialization ( TestCase ) : <EOL> def test_product_with_no_image_doesnt_blow_up ( self ) : <EOL> p = ProductFactory ( image = None ) <EOL> serializer = api . ProductSerializer ( ) <EOL> native = serializer . to_representation ( p ) <EOL> eq_ ( native [ '<STR_LIT:image>' ] , None ) <EOL> def test_product_with_image_works ( self ) : <EOL> p = ProductFactory ( ) <EOL> serializer = api . ProductSerializer ( ) <EOL> data = serializer . to_representation ( p ) <EOL> eq_ ( data [ '<STR_LIT:image>' ] , p . image . url ) <EOL> class TestTopicListView ( TestCase ) : <EOL> def test_it_works ( self ) : <EOL> p = ProductFactory ( ) <EOL> url = reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : p . slug } ) <EOL> res = self . client . get ( url ) <EOL> eq_ ( res . status_code , <NUM_LIT:200> ) <EOL> def test_expected_output ( self ) : <EOL> p = ProductFactory ( ) <EOL> t1 = TopicFactory ( product = p , visible = True , display_order = <NUM_LIT:1> ) <EOL> t2 = TopicFactory ( product = p , visible = True , display_order = <NUM_LIT:2> ) <EOL> url = reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : p . slug } ) <EOL> res = self . client . get ( url ) <EOL> eq_ ( res . status_code , <NUM_LIT:200> ) <EOL> eq_ ( res . data , { <EOL> '<STR_LIT:count>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : [ <EOL> { <EOL> '<STR_LIT:title>' : t1 . title , <EOL> '<STR_LIT>' : t1 . slug , <EOL> } , <EOL> { <EOL> '<STR_LIT:title>' : t2 . title , <EOL> '<STR_LIT>' : t2 . slug , <EOL> } , <EOL> ] , <EOL> } ) </s>
