@@ -49,30 +49,14 @@ def test_model(self):
4949 self .assertTrue (len (obj .keys ()) is 17 )
5050 self .assertTrue (len (obj .items ()) is 17 )
5151
52+ # check for expected data
5253 self .assertTrue ('type' in obj .keys ())
5354 self .assertTrue ('html' in obj .values ())
55+ self .assertEqual (obj ['type' ], 'html' )
56+ self .assertEqual (obj .get ('type' ), 'html' )
57+ self .assertEqual (obj .data ['type' ], 'html' )
58+ self .assertEqual (obj .data .get ('type' ), 'html' )
5459
55- #Get the object
56- self .assertTrue (obj .type == 'html' )
57- self .assertTrue (obj ['type' ] == 'html' )
58- self .assertTrue (obj .get ('type' ) == 'html' )
59-
60- #nope
61- self .assertTrue (obj .nothing is None )
62-
63- obj .nothing = 'something'
64- self .assertTrue (obj .nothing == 'something' )
65-
66- obj ['nothing' ] = 'maybe'
67- self .assertTrue (obj ['nothing' ] == 'maybe' )
68-
69- del obj ['nothing' ]
70- self .assertTrue (obj .nothing is None )
71-
72- #Deep Get attrs
73- self .assertTrue (obj .images [0 ].width is 275 )
74- self .assertTrue (obj .images [0 ].nothing is None )
75- self .assertTrue (obj .object .type is None )
7660 def test_model_data_can_serialize (self ):
7761 obj = Url ({'a' : {'key' : 'value' }})
7862 unserialzed = json .loads (json .dumps (obj .data ))
@@ -82,62 +66,62 @@ def test_provider(self):
8266 http = Embedly (self .key )
8367
8468 obj = http .oembed ('http://www.scribd.com/doc/13994900/Easter' )
85- self .assertTrue (obj . provider_url == 'http://www.scribd.com/' )
69+ self .assertEqual (obj [ ' provider_url' ], 'http://www.scribd.com/' )
8670
8771 obj = http .oembed ('http://www.scribd.com/doc/28452730/Easter-Cards' )
88- self .assertTrue (obj . provider_url == 'http://www.scribd.com/' )
72+ self .assertEqual (obj [ ' provider_url' ], 'http://www.scribd.com/' )
8973
9074 obj = http .oembed ('http://www.youtube.com/watch?v=Zk7dDekYej0' )
91- self .assertTrue (obj . provider_url == 'http://www.youtube.com/' )
75+ self .assertEqual (obj [ ' provider_url' ], 'http://www.youtube.com/' )
9276
9377 obj = http .oembed ('http://yfrog.com/h22eu4j' )
94- self .assertTrue (obj . provider_url == 'http://yfrog.com' )
78+ self .assertEqual (obj [ ' provider_url' ], 'http://yfrog.com' )
9579
9680 def test_providers (self ):
9781 http = Embedly (self .key )
9882
9983 objs = list (http .oembed (['http://www.scribd.com/doc/13994900/Easter' ,
10084 'http://www.scribd.com/doc/28452730/Easter-Cards' ]))
101- self .assertTrue (objs [0 ]. provider_url == 'http://www.scribd.com/' )
102- self .assertTrue (objs [1 ]. provider_url == 'http://www.scribd.com/' )
85+ self .assertEqual (objs [0 ][ ' provider_url' ], 'http://www.scribd.com/' )
86+ self .assertEqual (objs [1 ][ ' provider_url' ], 'http://www.scribd.com/' )
10387
10488 objs = list (http .oembed (['http://www.youtube.com/watch?v=Zk7dDekYej0' ,
10589 'http://yfrog.com/h22eu4' ]))
106- self .assertTrue (objs [0 ]. provider_url == 'http://www.youtube.com/' )
107- self .assertTrue (objs [1 ]. provider_url == 'http://yfrog.com' )
90+ self .assertEqual (objs [0 ][ ' provider_url' ], 'http://www.youtube.com/' )
91+ self .assertEqual (objs [1 ][ ' provider_url' ], 'http://yfrog.com' )
10892
10993 def test_error (self ):
11094 http = Embedly (self .key )
11195
11296 obj = http .oembed ('http://www.embedly.com/this/is/a/bad/url' )
113- self .assertTrue (obj . error is True , obj . dict )
97+ self .assertTrue (obj [ ' error' ] )
11498 obj = http .oembed ('http://blog.embed.ly/lsbsdlfldsf/asdfkljlas/klajsdlfkasdf' )
115- self .assertTrue (obj . error is True , obj . dict )
99+ self .assertTrue (obj [ ' error' ] )
116100 obj = http .oembed ('http://twitpic/nothing/to/see/here' )
117- self .assertTrue (obj . error is True , obj . dict )
101+ self .assertTrue (obj [ ' error' ] )
118102
119103 def test_multi_errors (self ):
120104 http = Embedly (self .key )
121105
122106 objs = list (http .oembed (['http://www.embedly.com/this/is/a/bad/url' ,
123107 'http://blog.embed.ly/alsd/slsdlf/asdlfj' ]))
124- self .assertTrue (objs [0 ]. type == 'error' , objs [ 0 ]. dict )
125- self .assertTrue (objs [1 ]. type == 'error' , objs [ 1 ]. dict )
108+ self .assertEqual (objs [0 ][ ' type' ], 'error' )
109+ self .assertEqual (objs [1 ][ ' type' ], 'error' )
126110
127111 objs = list (http .oembed (['http://blog.embed.ly/lsbsdlfldsf/asdf/kl' ,
128112 'http://twitpic.com/nothing/to/see/here' ]))
129- self .assertTrue (objs [0 ]. type == 'error' , objs [ 0 ]. dict )
130- self .assertTrue (objs [1 ]. type == 'error' , objs [ 1 ]. dict )
113+ self .assertEqual (objs [0 ][ ' type' ], 'error' )
114+ self .assertEqual (objs [1 ][ ' type' ], 'error' )
131115
132116 objs = list (http .oembed (['http://blog.embed.ly/lsbsdlfldsf/asdf/kl' ,
133117 'http://yfrog.com/h22eu4j' ]))
134- self .assertTrue (objs [0 ]. type == 'error' , objs [ 0 ]. dict )
135- self .assertTrue (objs [1 ]. type == 'photo' , objs [ 1 ]. dict )
118+ self .assertEqual (objs [0 ][ ' type' ], 'error' )
119+ self .assertEqual (objs [1 ][ ' type' ], 'photo' )
136120
137121 objs = list (http .oembed (['http://yfrog.com/h22eu4j' ,
138122 'http://www.scribd.com/asdf/asdf/asdfasdf' ]))
139- self .assertTrue (objs [0 ]. type == 'photo' , objs [ 0 ]. dict )
140- self .assertTrue (objs [1 ]. type == 'error' , objs [ 1 ]. dict )
123+ self .assertEqual (objs [0 ][ ' type' ], 'photo' )
124+ self .assertEqual (objs [1 ][ ' type' ], 'error' )
141125
142126 def test_too_many_urls (self ):
143127 http = Embedly (self .key )
@@ -151,4 +135,4 @@ def test_too_many_urls(self):
151135
152136
153137if __name__ == '__main__' :
154- unittest .main ()
138+ unittest .main ()
0 commit comments