1- from flask import url_for
1+ from flask import url_for , jsonify , json
22from flask .ext .login import current_user
33
44from app .test_base import BaseTestCase
55from app import app
66
77from .models import Photo
88from factory_responses import FactoryResponse
9-
9+ from app . data import db
1010
1111
1212class TestModelPhoto (BaseTestCase ):
@@ -16,13 +16,13 @@ def test_new_photo(self):
1616 self .assertTrue (photo .filepath ,'/test/photo.png' )
1717class TestFactoryResponses (BaseTestCase ):
1818 responses = None
19-
2019 @classmethod
2120 def setUpClass (cls ):
2221 cls .responses = FactoryResponse ()
2322 @classmethod
2423 def tearDownClass (cls ):
2524 cls .responses = None
25+
2626 def test_200_correct (self ):
2727 #TODO add respnse
2828 resp = self .responses .new200 ()
@@ -40,7 +40,6 @@ def test_202_correct(self):
4040
4141class TestPhotosViews (BaseTestCase ):
4242 def test_post_photo_correct (self ):
43-
4443 with self .app .open_resource ("test_resources/photo.jpg" ) as fp :
4544 with self .client :
4645 response = self .client .post ("/photos/v1.0/photos" ,data = {'file' :fp });
@@ -49,7 +48,8 @@ def test_post_photo_correct(self):
4948 self .app .logger .debug (response .json )
5049 #TODO add assert for correct response
5150 self .assertTrue (response .status_code == 201 )
52- def post_photo_not_allowed_file (self ):
51+
52+ def test_post_photo_not_allowed_file (self ):
5353 with self .app .open_resource ("test_resources/photo.txt" ) as fp :
5454 with self .client :
5555 response = self .client .post ("/photos/v1.0/photos" ,data = {'file' :fp });
@@ -58,3 +58,14 @@ def post_photo_not_allowed_file(self):
5858 #TODO add assert for correct response
5959 self .assertTrue (response .status_code == 202 )
6060
61+ def test_get_photo_correct (self ):
62+ #fake information
63+ data = {"uuid" :"1" ,"filepath" :"test1.jpg" }
64+ Photo .create (** data )
65+
66+ #fake data to test get resource
67+ with self .app .open_resource ("test_resources/photo.jpg" ) as fp :
68+ with self .client :
69+ response = self .client .get ("/photos/v1.0/photos" )
70+ app .logger .debug (response .json ['data' ][0 ]['uuid' ])
71+
0 commit comments