@@ -57,27 +57,27 @@ def test_zero_rows(self, mock_get):
5757
5858 @mock .patch .object (trovebox .Trovebox , 'get' )
5959 def test_options (self , mock_get ):
60- """Check that the activity list options are applied properly"""
60+ """Check that the photo list options are applied properly"""
6161 mock_get .return_value = self ._return_value (self .test_photos_dict )
6262 self .client .photos .list (options = {"foo" : "bar" ,
63- "test1" : "test2 " },
63+ "test1" : "\xfc mlaut " },
6464 foo = "bar" )
6565 # Dict element can be any order
6666 self .assertIn (mock_get .call_args [0 ],
67- [("/photos/foo-bar/test1-test2 /list.json" ,),
68- ("/photos/test1-test2 /foo-bar/list.json" ,)])
67+ [("/photos/foo-bar/test1-%C3%BCmlaut /list.json" ,),
68+ ("/photos/test1-%C3%BCmlaut /foo-bar/list.json" ,)])
6969 self .assertEqual (mock_get .call_args [1 ], {"foo" : "bar" })
7070
7171class TestPhotosShare (TestPhotos ):
7272 @mock .patch .object (trovebox .Trovebox , 'post' )
7373 def test_photos_share (self , mock_post ):
7474 self .client .photos .share (options = {"foo" : "bar" ,
75- "test1" : "test2 " },
75+ "test1" : "\xfc mlaut " },
7676 foo = "bar" )
7777 # Dict element can be any order
7878 self .assertIn (mock_post .call_args [0 ],
79- [("/photos/foo-bar/test1-test2 /share.json" ,),
80- ("/photos/test1-test2 /foo-bar/share.json" ,)])
79+ [("/photos/foo-bar/test1-%C3%BCmlaut /share.json" ,),
80+ ("/photos/test1-%C3%BCmlaut /foo-bar/share.json" ,)])
8181 self .assertEqual (mock_post .call_args [1 ], {"foo" : "bar" })
8282
8383class TestPhotosUpdate (TestPhotos ):
@@ -363,12 +363,12 @@ def test_photo_view(self, mock_get):
363363 mock_get .return_value = self ._return_value (self .test_photos_dict [1 ])
364364 result = self .client .photo .view (self .test_photos [0 ],
365365 options = {"foo" : "bar" ,
366- "test1" : "test2 " },
366+ "test1" : "\xfc mlaut " },
367367 returnSizes = "20x20" )
368368 # Dict elemet can be in any order
369369 self .assertIn (mock_get .call_args [0 ],
370- [("/photo/1a/foo-bar/test1-test2 /view.json" ,),
371- ("/photo/1a/test1-test2 /foo-bar/view.json" ,)])
370+ [("/photo/1a/foo-bar/test1-%C3%BCmlaut /view.json" ,),
371+ ("/photo/1a/test1-%C3%BCmlaut /foo-bar/view.json" ,)])
372372 self .assertEqual (mock_get .call_args [1 ], {"returnSizes" : "20x20" })
373373 self .assertEqual (result .get_fields (), self .test_photos_dict [1 ])
374374
@@ -378,13 +378,13 @@ def test_photo_view_id(self, mock_get):
378378 mock_get .return_value = self ._return_value (self .test_photos_dict [1 ])
379379 result = self .client .photo .view ("1a" ,
380380 options = {"foo" : "bar" ,
381- "test1" : "test2 " },
381+ "test1" : "\xfc mlaut " },
382382 returnSizes = "20x20" )
383383
384384 # Dict elemet can be in any order
385385 self .assertIn (mock_get .call_args [0 ],
386- [("/photo/1a/foo-bar/test1-test2 /view.json" ,),
387- ("/photo/1a/test1-test2 /foo-bar/view.json" ,)])
386+ [("/photo/1a/foo-bar/test1-%C3%BCmlaut /view.json" ,),
387+ ("/photo/1a/test1-%C3%BCmlaut /foo-bar/view.json" ,)])
388388 self .assertEqual (mock_get .call_args [1 ], {"returnSizes" : "20x20" })
389389 self .assertEqual (result .get_fields (), self .test_photos_dict [1 ])
390390
@@ -419,7 +419,7 @@ def test_photo_upload(self, mock_post):
419419 files = mock_post .call_args [1 ]["files" ]
420420 self .assertEqual (endpoint , ("/photo/upload.json" ,))
421421 self .assertEqual (title , "Test" )
422- self .assertIn ( "photo" , files )
422+ self .assertEqual ( files [ "photo" ]. name , self . test_file )
423423 self .assertEqual (result .get_fields (), self .test_photos_dict [0 ])
424424
425425class TestPhotoUploadEncoded (TestPhotos ):
@@ -455,12 +455,12 @@ def test_photo_next_previous(self, mock_get):
455455 "previous" : [self .test_photos_dict [1 ]]})
456456 result = self .client .photo .next_previous (self .test_photos [0 ],
457457 options = {"foo" : "bar" ,
458- "test1" : "test2 " },
458+ "test1" : "\xfc mlaut " },
459459 foo = "bar" )
460460 # Dict elemet can be in any order
461461 self .assertIn (mock_get .call_args [0 ],
462- [("/photo/1a/nextprevious/foo-bar/test1-test2 .json" ,),
463- ("/photo/1a/nextprevious/test1-test2 /foo-bar.json" ,)])
462+ [("/photo/1a/nextprevious/foo-bar/test1-%C3%BCmlaut .json" ,),
463+ ("/photo/1a/nextprevious/test1-%C3%BCmlaut /foo-bar.json" ,)])
464464 self .assertEqual (mock_get .call_args [1 ], {"foo" : "bar" })
465465 self .assertEqual (result ["next" ][0 ].get_fields (),
466466 self .test_photos_dict [0 ])
@@ -478,12 +478,12 @@ def test_photo_next_previous_id(self, mock_get):
478478 "previous" : [self .test_photos_dict [1 ]]})
479479 result = self .client .photo .next_previous ("1a" ,
480480 options = {"foo" : "bar" ,
481- "test1" : "test2 " },
481+ "test1" : "\xfc mlaut " },
482482 foo = "bar" )
483483 # Dict elemet can be in any order
484484 self .assertIn (mock_get .call_args [0 ],
485- [("/photo/1a/nextprevious/foo-bar/test1-test2 .json" ,),
486- ("/photo/1a/nextprevious/test1-test2 /foo-bar.json" ,)])
485+ [("/photo/1a/nextprevious/foo-bar/test1-%C3%BCmlaut .json" ,),
486+ ("/photo/1a/nextprevious/test1-%C3%BCmlaut /foo-bar.json" ,)])
487487 self .assertEqual (mock_get .call_args [1 ], {"foo" : "bar" })
488488 self .assertEqual (result ["next" ][0 ].get_fields (),
489489 self .test_photos_dict [0 ])
@@ -500,12 +500,12 @@ def test_photo_object_next_previous(self, mock_get):
500500 {"next" : [self .test_photos_dict [0 ]],
501501 "previous" : [self .test_photos_dict [1 ]]})
502502 result = self .test_photos [0 ].next_previous (options = {"foo" : "bar" ,
503- "test1" : "test2 " },
503+ "test1" : "\xfc mlaut " },
504504 foo = "bar" )
505505 # Dict elemet can be in any order
506506 self .assertIn (mock_get .call_args [0 ],
507- [("/photo/1a/nextprevious/foo-bar/test1-test2 .json" ,),
508- ("/photo/1a/nextprevious/test1-test2 /foo-bar.json" ,)])
507+ [("/photo/1a/nextprevious/foo-bar/test1-%C3%BCmlaut .json" ,),
508+ ("/photo/1a/nextprevious/test1-%C3%BCmlaut /foo-bar.json" ,)])
509509 self .assertEqual (mock_get .call_args [1 ], {"foo" : "bar" })
510510 self .assertEqual (result ["next" ][0 ].get_fields (),
511511 self .test_photos_dict [0 ])
@@ -606,6 +606,11 @@ def test_photo_object_repr_with_id_and_name(self):
606606 "name" : "Test Name" })
607607 self .assertEqual (repr (photo ), "<Photo name='Test Name'>" )
608608
609+ def test_photo_object_repr_with_unicode_id (self ):
610+ """ Ensure that a unicode id is correctly represented """
611+ photo = trovebox .objects .photo .Photo (self .client , {"id" : "\xfc mlaut" })
612+ self .assertIn (repr (photo ), [b"<Photo id='\xc3 \xbc mlaut'>" , "<Photo id='\xfc mlaut'>" ])
613+
609614 @mock .patch .object (trovebox .Trovebox , 'post' )
610615 def test_photo_object_create_attribute (self , _ ):
611616 """
0 commit comments