2007-07-16 20:22:38 +00:00
|
|
|
import cherrypy
|
2007-10-17 07:53:42 +00:00
|
|
|
from model.Note import Note
|
|
|
|
from model.Notebook import Notebook
|
2007-10-11 19:49:00 +00:00
|
|
|
from model.User import User
|
2007-07-16 20:22:38 +00:00
|
|
|
from Test_controller import Test_controller
|
|
|
|
|
|
|
|
|
|
|
|
class Test_root( Test_controller ):
|
|
|
|
def setUp( self ):
|
|
|
|
Test_controller.setUp( self )
|
|
|
|
|
2008-03-01 00:26:06 +00:00
|
|
|
self.notebook = Notebook.create( self.database.next_id( Notebook ), u"my notebook", trash_id = u"foo" )
|
2007-10-17 07:53:42 +00:00
|
|
|
self.database.save( self.notebook )
|
|
|
|
|
2007-10-30 23:05:46 +00:00
|
|
|
self.anon_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes" )
|
2007-10-17 07:53:42 +00:00
|
|
|
self.database.save( self.anon_notebook )
|
|
|
|
self.anon_note = Note.create(
|
|
|
|
self.database.next_id( Note ), u"<h3>my note</h3>",
|
|
|
|
notebook_id = self.anon_notebook.object_id,
|
|
|
|
)
|
|
|
|
self.database.save( self.anon_note )
|
|
|
|
|
2008-03-01 00:26:06 +00:00
|
|
|
self.login_note = Note.create(
|
|
|
|
self.database.next_id( Note ), u"<h3>login</h3>",
|
|
|
|
notebook_id = self.anon_notebook.object_id,
|
|
|
|
)
|
|
|
|
self.database.save( self.login_note )
|
|
|
|
|
2007-10-30 23:05:46 +00:00
|
|
|
self.blog_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes blog" )
|
|
|
|
self.database.save( self.blog_notebook )
|
|
|
|
self.blog_note = Note.create(
|
|
|
|
self.database.next_id( Note ), u"<h3>my blog entry</h3>",
|
|
|
|
notebook_id = self.blog_notebook.object_id,
|
|
|
|
)
|
|
|
|
self.database.save( self.blog_note )
|
|
|
|
|
2007-11-06 22:42:53 +00:00
|
|
|
self.guide_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes user guide" )
|
|
|
|
self.database.save( self.guide_notebook )
|
|
|
|
self.guide_note = Note.create(
|
|
|
|
self.database.next_id( Note ), u"<h3>it's all self-explanatory</h3>",
|
|
|
|
notebook_id = self.guide_notebook.object_id,
|
|
|
|
)
|
|
|
|
self.database.save( self.guide_note )
|
|
|
|
|
2007-11-13 00:59:19 +00:00
|
|
|
self.privacy_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes privacy policy" )
|
|
|
|
self.database.save( self.privacy_notebook )
|
|
|
|
self.privacy_note = Note.create(
|
|
|
|
self.database.next_id( Note ), u"<h3>yay privacy</h3>",
|
|
|
|
notebook_id = self.privacy_notebook.object_id,
|
|
|
|
)
|
|
|
|
self.database.save( self.privacy_note )
|
|
|
|
|
2007-08-02 23:25:57 +00:00
|
|
|
self.username = u"mulder"
|
|
|
|
self.password = u"trustno1"
|
|
|
|
self.email_address = u"outthere@example.com"
|
|
|
|
self.user = None
|
|
|
|
self.session_id = None
|
|
|
|
|
Merged revisions 401-446 via svnmerge from
svn+ssh://torsion.org/home/luminotes/repos/luminotes/branches/postgres
................
r402 | witten | 2007-10-04 00:48:49 -0700 (Thu, 04 Oct 2007) | 3 lines
Initialized merge tracking via "svnmerge" with revisions "1-401" from
svn+ssh://torsion.org/home/luminotes/repos/luminotes/trunk
................
r404 | witten | 2007-10-04 01:17:07 -0700 (Thu, 04 Oct 2007) | 2 lines
Beginning a conversion from bsddb to postgres.
................
r405 | witten | 2007-10-04 01:18:58 -0700 (Thu, 04 Oct 2007) | 9 lines
Merged revisions 402-404 via svnmerge from
svn+ssh://torsion.org/home/luminotes/repos/luminotes/trunk
........
r403 | witten | 2007-10-04 01:14:45 -0700 (Thu, 04 Oct 2007) | 2 lines
Yay, no more stupid deprecation warnings from simplejson about the sre module.
........
................
r406 | witten | 2007-10-04 15:34:39 -0700 (Thu, 04 Oct 2007) | 4 lines
* Switched back to Python 2.4 because many Python modules in Debian are not packaged to work with Python 2.5
* Began removal of all references to Scheduler, @async, yield, and so on.
* Converted Database.py to support PostgreSQL and updated its unit tests accordingly.
................
r407 | witten | 2007-10-04 16:34:01 -0700 (Thu, 04 Oct 2007) | 2 lines
All unit tests for the new model classes now pass.
................
r409 | witten | 2007-10-05 00:53:56 -0700 (Fri, 05 Oct 2007) | 2 lines
Reordering some columns and adding some indices.
................
r410 | witten | 2007-10-05 16:08:37 -0700 (Fri, 05 Oct 2007) | 4 lines
Now adding trash notebooks to user_notebook table. Also switching db
conversion/verification tools back to require Python 2.5, since they still use
the old Scheduler, which requires 2.5 generator features.
................
r411 | witten | 2007-10-06 16:26:56 -0700 (Sat, 06 Oct 2007) | 2 lines
Lots more unit tests passing. Most of the recent work was on controller.Users and related stuff.
................
r412 | witten | 2007-10-07 01:52:12 -0700 (Sun, 07 Oct 2007) | 2 lines
controller.Users unit tests now finally pass!
................
r413 | witten | 2007-10-07 02:14:10 -0700 (Sun, 07 Oct 2007) | 3 lines
Got controller.Root unit tests passing.
Moved fake sql_* function shenanigans from Test_users.py to Test_controller.py, for use by other controller unit tests.
................
r414 | witten | 2007-10-08 23:11:11 -0700 (Mon, 08 Oct 2007) | 2 lines
All unit tests pass! Fuck yeah!
................
r415 | witten | 2007-10-08 23:13:07 -0700 (Mon, 08 Oct 2007) | 2 lines
Removing all references to Scheduler from luminotes.py
................
r416 | witten | 2007-10-08 23:54:51 -0700 (Mon, 08 Oct 2007) | 3 lines
Converted deleted_from to deleted_from_id in a few more places.
Fixed bug in Users.contents().
................
r417 | witten | 2007-10-09 00:11:59 -0700 (Tue, 09 Oct 2007) | 3 lines
Typo fix in Note sql method.
Adding autocommit flag to Database.next_id() method.
................
r418 | witten | 2007-10-09 00:13:19 -0700 (Tue, 09 Oct 2007) | 2 lines
Updating unit test for new auto commit flag.
................
r419 | witten | 2007-10-09 00:14:09 -0700 (Tue, 09 Oct 2007) | 2 lines
Removing debugging print.
................
r420 | witten | 2007-10-09 00:20:55 -0700 (Tue, 09 Oct 2007) | 2 lines
More sql fixes. I really need some funtional tests that hit the database and exercise the SQL.
................
r421 | witten | 2007-10-09 00:51:34 -0700 (Tue, 09 Oct 2007) | 3 lines
Fixed controller.Database handling of tuple as an Object_type.
Made SQL for user storage calculation better at handling null values and also more succinct.
................
r422 | witten | 2007-10-09 13:32:16 -0700 (Tue, 09 Oct 2007) | 2 lines
Converting Wiki.js to trash_id notebook member instead of trash object.
................
r423 | witten | 2007-10-09 13:42:10 -0700 (Tue, 09 Oct 2007) | 2 lines
No longer displaying "download as html" on the front page, as people see "download" and think they're downloading the software.
................
r424 | witten | 2007-10-09 14:24:40 -0700 (Tue, 09 Oct 2007) | 2 lines
Notebooks.contents() now returns notebooks with correct read-write status.
................
r425 | witten | 2007-10-09 14:32:25 -0700 (Tue, 09 Oct 2007) | 2 lines
Fixed reporting of validation errors to the user. Now says "The blah is missing." instead of just "is missing"
................
r426 | witten | 2007-10-09 17:05:22 -0700 (Tue, 09 Oct 2007) | 2 lines
No longer redirecting to trash notebook upon login.
................
r427 | witten | 2007-10-09 17:20:33 -0700 (Tue, 09 Oct 2007) | 2 lines
Made controller.Database use a connection pool.
................
r429 | witten | 2007-10-09 20:13:30 -0700 (Tue, 09 Oct 2007) | 2 lines
Converted initdb.py and updatedb.py to Postgres from bsddb.
................
r430 | witten | 2007-10-09 20:37:14 -0700 (Tue, 09 Oct 2007) | 2 lines
Changing error message to remove underscores from variable names.
................
r431 | witten | 2007-10-10 13:23:30 -0700 (Wed, 10 Oct 2007) | 2 lines
Removing unused note_title parameter from Wiki.create_editor().
................
r432 | witten | 2007-10-10 13:25:16 -0700 (Wed, 10 Oct 2007) | 2 lines
Revision regular expression now supports timezone notation.
................
r433 | witten | 2007-10-10 14:43:47 -0700 (Wed, 10 Oct 2007) | 2 lines
Finished implementing ranked ordering for startup notes. (However, there's no way to change the rank from the client yet.)
................
r434 | witten | 2007-10-10 16:25:19 -0700 (Wed, 10 Oct 2007) | 4 lines
More strict access checking. Fixed oversight in Postgres DB conversion where,
in certain controller.Notebook methods, access was only checked at the
notebook level, not at the note level as well.
................
r435 | witten | 2007-10-10 17:45:18 -0700 (Wed, 10 Oct 2007) | 3 lines
Now loading revisions on demand from client when the "changes" button is clicked. Also caching
loading revisions so subsequent clicks don't have to reload.
................
r436 | witten | 2007-10-10 21:31:20 -0700 (Wed, 10 Oct 2007) | 2 lines
Tweaking some of the error handling in Expose and Root so that unhandled errors give a generic error message to the client.
................
r437 | witten | 2007-10-10 21:33:49 -0700 (Wed, 10 Oct 2007) | 2 lines
The release script no longer runs initdb.py, because the default database is no longer a single file included in the tarball.
................
r438 | witten | 2007-10-10 21:40:11 -0700 (Wed, 10 Oct 2007) | 2 lines
Updated install instructuctions to include use of initdb.py.
................
r439 | witten | 2007-10-10 21:56:42 -0700 (Wed, 10 Oct 2007) | 3 lines
Made initdb.py only nuke (drop tables/views) when given a command-line flag.
Also made install directions more correct.
................
r440 | witten | 2007-10-10 21:58:48 -0700 (Wed, 10 Oct 2007) | 2 lines
IE 6 doesn't like commas.
................
r441 | witten | 2007-10-10 22:08:50 -0700 (Wed, 10 Oct 2007) | 4 lines
load your notebook. without clicking on "changes", edit a note that has previous revisions. click on "changes". it'll only show
the most recent revision. fixed by not appending to changes as a result of a save unless the client-side revisions list cache has
something in it
................
r442 | witten | 2007-10-10 23:30:41 -0700 (Wed, 10 Oct 2007) | 2 lines
Forgot to actually save off the new revision as editor.revision.
................
r443 | witten | 2007-10-11 01:35:54 -0700 (Thu, 11 Oct 2007) | 13 lines
More intelligent datetime handling:
* convertdb.py assumes old bsddb database timestamps are Pacific, and then
converts them to UTC before inserting them into the new PostgreSQL
database.
* No longer using naked timezoneless datetime objects in model/controller
code, except in unit tests that need compatability with pysqlite. Now
using UTC everwhere.
* Asking PostgreSQL to give us all timestamps back in UTC.
* New dependency on python-tz (pytz) package, noted in INSTALL doc.
* Client now responsible for converting UTC timestamps to local time for
display.
................
r444 | witten | 2007-10-11 01:46:09 -0700 (Thu, 11 Oct 2007) | 2 lines
Tweak to prevent potential race in IE.
................
r445 | witten | 2007-10-11 01:49:58 -0700 (Thu, 11 Oct 2007) | 2 lines
Got JavaScript "unit" tests passing again.
................
r446 | witten | 2007-10-11 01:53:58 -0700 (Thu, 11 Oct 2007) | 2 lines
Noting that js tests require the Luminotes server on localhost.
................
2007-10-11 09:03:43 +00:00
|
|
|
self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address )
|
2007-08-02 23:25:57 +00:00
|
|
|
self.database.save( self.user )
|
2007-10-17 07:53:42 +00:00
|
|
|
self.database.execute( self.user.sql_save_notebook( self.notebook.object_id ) )
|
|
|
|
|
|
|
|
self.anonymous = User.create( self.database.next_id( User ), u"anonymous" )
|
|
|
|
self.database.save( self.anonymous )
|
2008-10-24 18:51:19 +00:00
|
|
|
self.database.execute( self.anonymous.sql_save_notebook( self.anon_notebook.object_id, read_write = False, owner = False, rank = 0 ) )
|
|
|
|
self.database.execute( self.anonymous.sql_save_notebook( self.blog_notebook.object_id, read_write = False, owner = False, rank = 1 ) )
|
|
|
|
self.database.execute( self.anonymous.sql_save_notebook( self.guide_notebook.object_id, read_write = False, owner = False, rank = 2 ) )
|
|
|
|
self.database.execute( self.anonymous.sql_save_notebook( self.privacy_notebook.object_id, read_write = False, owner = False, rank = 3 ) )
|
2007-08-02 23:25:57 +00:00
|
|
|
|
2007-07-16 20:22:38 +00:00
|
|
|
def test_index( self ):
|
|
|
|
result = self.http_get( "/" )
|
2007-11-15 01:30:45 +00:00
|
|
|
|
2007-07-16 20:22:38 +00:00
|
|
|
assert result
|
2008-03-01 00:26:06 +00:00
|
|
|
assert result.get( u"redirect" ) is None
|
|
|
|
assert result[ u"user" ].username == u"anonymous"
|
|
|
|
assert len( result[ u"notebooks" ] ) == 4
|
|
|
|
assert result[ u"first_notebook" ] == None
|
|
|
|
assert result[ u"login_url" ] == u"https://luminotes.com/notebooks/%s?note_id=%s" % (
|
|
|
|
self.anon_notebook.object_id, self.login_note.object_id,
|
|
|
|
)
|
|
|
|
assert result[ u"logout_url" ] == u"https://luminotes.com/users/logout"
|
|
|
|
assert result[ u"rate_plan" ]
|
2007-07-16 20:22:38 +00:00
|
|
|
|
2008-03-01 00:26:06 +00:00
|
|
|
def test_index_after_login_without_referer( self ):
|
2007-08-02 23:25:57 +00:00
|
|
|
self.login()
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/",
|
|
|
|
session_id = self.session_id,
|
|
|
|
)
|
|
|
|
|
2008-03-01 00:26:06 +00:00
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) == u"https://luminotes.com/notebooks/%s" % self.notebook.object_id
|
2007-08-02 23:25:57 +00:00
|
|
|
|
2008-03-01 00:26:06 +00:00
|
|
|
def test_index_after_login_with_referer( self ):
|
|
|
|
self.login()
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/",
|
|
|
|
headers = [ ( u"Referer", "http://whee" ) ],
|
|
|
|
session_id = self.session_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) == u"https://luminotes.com/"
|
|
|
|
|
|
|
|
def test_index_with_https_after_login_without_referer( self ):
|
2007-08-03 19:43:16 +00:00
|
|
|
self.login()
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/",
|
|
|
|
session_id = self.session_id,
|
|
|
|
pretend_https = True,
|
|
|
|
)
|
|
|
|
|
2008-03-01 00:26:06 +00:00
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) == u"https://luminotes.com/notebooks/%s" % self.notebook.object_id
|
|
|
|
|
|
|
|
def test_index_with_https_after_login_with_referer( self ):
|
|
|
|
self.login()
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/",
|
|
|
|
session_id = self.session_id,
|
|
|
|
headers = [ ( u"Referer", "http://whee" ) ],
|
|
|
|
pretend_https = True,
|
|
|
|
)
|
|
|
|
|
2007-08-03 19:43:16 +00:00
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) is None
|
2008-03-01 00:26:06 +00:00
|
|
|
assert result[ u"user" ].username == self.user.username
|
2009-01-29 23:30:10 +00:00
|
|
|
assert len( result[ u"notebooks" ] ) == 1
|
2008-03-01 00:26:06 +00:00
|
|
|
assert result[ u"first_notebook" ].object_id == self.notebook.object_id
|
|
|
|
assert result[ u"login_url" ] == None
|
|
|
|
assert result[ u"logout_url" ] == u"https://luminotes.com/users/logout"
|
|
|
|
assert result[ u"rate_plan" ]
|
2007-08-03 19:43:16 +00:00
|
|
|
|
2008-08-21 04:56:20 +00:00
|
|
|
def test_index_auto_login( self ):
|
|
|
|
self.settings[ u"global" ][ u"luminotes.auto_login_username" ] = self.username
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/",
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) == u"/notebooks/%s" % self.notebook.object_id
|
|
|
|
|
|
|
|
# confirm that we're now logged in and can access the user's notebook without an error
|
|
|
|
result = self.http_get(
|
|
|
|
result.get( u"redirect" ),
|
|
|
|
session_id = self.session_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert u"error" not in result
|
|
|
|
|
|
|
|
def test_index_auto_login_while_already_logged_in( self ):
|
|
|
|
self.login()
|
|
|
|
|
|
|
|
self.settings[ u"global" ][ u"luminotes.auto_login_username" ] = self.username
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/",
|
|
|
|
session_id = self.session_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) == u"/notebooks/%s" % self.notebook.object_id
|
|
|
|
|
|
|
|
# confirm that we're now logged in and can access the user's notebook without an error
|
|
|
|
result = self.http_get(
|
|
|
|
result.get( u"redirect" ),
|
|
|
|
session_id = self.session_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert u"error" not in result
|
|
|
|
|
|
|
|
def test_index_auto_login_with_unknown_username( self ):
|
|
|
|
self.settings[ u"global" ][ u"luminotes.auto_login_username" ] = u"unknownusername"
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/",
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) is None
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
u"/notebooks/%s" % self.notebook.object_id,
|
|
|
|
session_id = self.session_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result.get( "status" ) == "302 Found" # redirect to login page
|
|
|
|
|
2008-03-13 20:45:45 +00:00
|
|
|
def test_tour( self ):
|
|
|
|
result = self.http_get( u"/tour" )
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) is None
|
|
|
|
assert result[ u"user" ].username == u"anonymous"
|
|
|
|
assert len( result[ u"notebooks" ] ) == 4
|
|
|
|
assert result[ u"first_notebook" ] == None
|
|
|
|
assert result[ u"login_url" ] == u"https://luminotes.com/notebooks/%s?note_id=%s" % (
|
|
|
|
self.anon_notebook.object_id, self.login_note.object_id,
|
|
|
|
)
|
|
|
|
assert result[ u"logout_url" ] == u"https://luminotes.com/users/logout"
|
|
|
|
assert result[ u"rate_plan" ]
|
|
|
|
|
|
|
|
def test_take_a_tour( self ):
|
|
|
|
result = self.http_get( u"/take_a_tour" )
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) == u"/tour"
|
|
|
|
|
|
|
|
def test_tour_after_login( self ):
|
|
|
|
self.login()
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
u"/tour",
|
|
|
|
session_id = self.session_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) is None
|
|
|
|
assert result[ u"user" ].username == self.user.username
|
2009-01-29 23:30:10 +00:00
|
|
|
assert len( result[ u"notebooks" ] ) == 1
|
2008-03-13 20:45:45 +00:00
|
|
|
assert result[ u"first_notebook" ].object_id == self.notebook.object_id
|
|
|
|
assert result[ u"login_url" ] == None
|
|
|
|
assert result[ u"logout_url" ] == u"https://luminotes.com/users/logout"
|
|
|
|
assert result[ u"rate_plan" ]
|
|
|
|
|
|
|
|
def test_take_a_tour_after_login( self ):
|
|
|
|
self.login()
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
u"/take_a_tour",
|
|
|
|
session_id = self.session_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( u"redirect" ) == u"/tour"
|
|
|
|
|
2007-10-17 07:53:42 +00:00
|
|
|
def test_default( self ):
|
|
|
|
result = self.http_get(
|
|
|
|
"/my_note",
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
2007-10-30 23:05:46 +00:00
|
|
|
assert result[ u"notes" ]
|
|
|
|
assert len( result[ u"notes" ] ) == 1
|
|
|
|
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
|
2007-11-15 01:30:45 +00:00
|
|
|
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
|
2008-01-05 00:42:50 +00:00
|
|
|
assert result[ u"user" ].object_id == self.anonymous.object_id
|
2007-10-17 07:53:42 +00:00
|
|
|
|
2007-12-27 22:16:47 +00:00
|
|
|
def test_default_with_invite_id( self ):
|
|
|
|
result = self.http_get(
|
|
|
|
"/my_note?invite_id=whee",
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result[ u"notes" ]
|
|
|
|
assert len( result[ u"notes" ] ) == 1
|
|
|
|
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
|
|
|
|
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
|
|
|
|
assert result[ u"invite_id" ] == u"whee"
|
2008-01-05 00:42:50 +00:00
|
|
|
assert result[ u"user" ].object_id == self.anonymous.object_id
|
|
|
|
|
2008-01-10 08:33:19 +00:00
|
|
|
def test_default_with_after_login( self ):
|
|
|
|
after_login = "/foo/bar"
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/my_note?after_login=%s" % after_login,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result[ u"notes" ]
|
|
|
|
assert len( result[ u"notes" ] ) == 1
|
|
|
|
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
|
|
|
|
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
|
|
|
|
assert result[ u"after_login" ] == after_login
|
|
|
|
assert result[ u"user" ].object_id == self.anonymous.object_id
|
|
|
|
|
|
|
|
def test_default_with_after_login_with_full_url( self ):
|
|
|
|
after_login = "http://example.com/foo/bar"
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/my_note?after_login=%s" % after_login,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result[ u"notes" ]
|
|
|
|
assert len( result[ u"notes" ] ) == 1
|
|
|
|
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
|
|
|
|
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
|
|
|
|
assert result.get( u"after_login" ) is None
|
|
|
|
assert result[ u"user" ].object_id == self.anonymous.object_id
|
|
|
|
|
2008-03-24 22:33:00 +00:00
|
|
|
def test_default_with_plan( self ):
|
|
|
|
plan = u"17"
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/my_note?plan=%s" % plan,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result[ u"notes" ]
|
|
|
|
assert len( result[ u"notes" ] ) == 1
|
|
|
|
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
|
|
|
|
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
|
|
|
|
assert result[ u"signup_plan" ] == 17
|
|
|
|
assert result[ u"user" ].object_id == self.anonymous.object_id
|
|
|
|
|
2008-05-08 19:14:39 +00:00
|
|
|
def test_default_with_plan_and_yearly( self ):
|
|
|
|
plan = u"17"
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/my_note?plan=%s&yearly=True" % plan,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result[ u"notes" ]
|
|
|
|
assert len( result[ u"notes" ] ) == 1
|
|
|
|
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
|
|
|
|
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
|
|
|
|
assert result[ u"signup_plan" ] == 17
|
|
|
|
assert result[ u"user" ].object_id == self.anonymous.object_id
|
|
|
|
|
2008-01-05 00:42:50 +00:00
|
|
|
def test_default_after_login( self ):
|
|
|
|
self.login()
|
|
|
|
|
|
|
|
result = self.http_get(
|
|
|
|
"/my_note",
|
|
|
|
session_id = self.session_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result[ u"notes" ]
|
|
|
|
assert len( result[ u"notes" ] ) == 1
|
|
|
|
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
|
|
|
|
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
|
|
|
|
assert result[ u"user" ].object_id == self.user.object_id
|
2007-12-27 22:16:47 +00:00
|
|
|
|
2007-10-17 07:53:42 +00:00
|
|
|
def test_default_with_unknown_note( self ):
|
|
|
|
result = self.http_get(
|
|
|
|
"/unknown_note",
|
|
|
|
)
|
|
|
|
|
|
|
|
body = result.get( u"body" )
|
|
|
|
assert body
|
|
|
|
assert len( body ) > 0
|
|
|
|
assert u"404" in body[ 0 ]
|
|
|
|
|
|
|
|
def test_default_with_login_note( self ):
|
|
|
|
result = self.http_get(
|
|
|
|
"/login",
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( "redirect" )
|
|
|
|
assert result.get( "redirect" ).startswith( "https://" )
|
|
|
|
|
|
|
|
def test_default_with_sign_up_note( self ):
|
|
|
|
result = self.http_get(
|
|
|
|
"/sign_up",
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert result.get( "redirect" )
|
|
|
|
assert result.get( "redirect" ).startswith( "https://" )
|
|
|
|
|
2007-11-06 22:42:53 +00:00
|
|
|
def test_guide( self ):
|
|
|
|
result = self.http_get(
|
|
|
|
"/guide",
|
2007-11-13 00:59:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert u"error" not in result
|
2007-11-15 01:30:45 +00:00
|
|
|
assert result[ u"notebook" ].object_id == self.guide_notebook.object_id
|
2007-11-13 00:59:19 +00:00
|
|
|
|
2008-07-03 23:29:42 +00:00
|
|
|
def test_guide_with_note_id( self ):
|
|
|
|
result = self.http_get(
|
|
|
|
"/guide?note_id=%s" % self.guide_note.object_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
|
|
|
assert u"error" not in result
|
|
|
|
assert result[ u"notebook" ].object_id == self.guide_notebook.object_id
|
|
|
|
|
2007-11-13 00:59:19 +00:00
|
|
|
def test_privacy( self ):
|
|
|
|
result = self.http_get(
|
|
|
|
"/privacy",
|
2007-11-06 22:42:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result
|
2007-11-10 03:57:27 +00:00
|
|
|
assert u"error" not in result
|
2007-11-15 01:30:45 +00:00
|
|
|
assert result[ u"notebook" ].object_id == self.privacy_notebook.object_id
|
2007-11-06 22:42:53 +00:00
|
|
|
|
2008-03-22 04:01:21 +00:00
|
|
|
def test_pricing( self ):
|
|
|
|
result = self.http_get( "/pricing" )
|
2008-01-10 08:33:19 +00:00
|
|
|
|
|
|
|
assert result[ u"user" ].username == u"anonymous"
|
|
|
|
assert len( result[ u"notebooks" ] ) == 4
|
2008-08-19 22:05:40 +00:00
|
|
|
notebook = [ notebook for notebook in result[ u"notebooks" ] if notebook.object_id == self.anon_notebook.object_id ][ 0 ]
|
|
|
|
assert notebook.object_id == self.anon_notebook.object_id
|
|
|
|
assert notebook.name == self.anon_notebook.name
|
2008-10-24 18:51:19 +00:00
|
|
|
assert notebook.read_write == Notebook.READ_ONLY
|
2008-08-19 22:05:40 +00:00
|
|
|
assert notebook.owner == False
|
2008-01-10 08:33:19 +00:00
|
|
|
|
|
|
|
rate_plan = result[ u"rate_plan" ]
|
|
|
|
assert rate_plan
|
|
|
|
assert rate_plan[ u"name" ] == u"super"
|
2008-02-23 23:57:05 +00:00
|
|
|
assert rate_plan[ u"storage_quota_bytes" ] == 1337 * 10
|
2008-01-10 08:33:19 +00:00
|
|
|
|
2008-03-22 04:01:21 +00:00
|
|
|
assert result[ u"first_notebook" ] == None
|
|
|
|
assert result[ u"rate_plans" ] == self.settings[ u"global" ].get( u"luminotes.rate_plans", [] )
|
|
|
|
assert result[ u"unsubscribe_button" ] == self.settings[ u"global" ].get( u"luminotes.unsubscribe_button" )
|
2008-01-10 08:33:19 +00:00
|
|
|
|
2008-03-22 04:01:21 +00:00
|
|
|
def test_pricing_after_login( self ):
|
2008-01-10 08:33:19 +00:00
|
|
|
self.login()
|
|
|
|
|
2008-03-22 04:01:21 +00:00
|
|
|
result = self.http_get( "/pricing", session_id = self.session_id )
|
2008-01-10 08:33:19 +00:00
|
|
|
|
|
|
|
assert result[ u"user" ].username == self.username
|
2009-01-29 23:30:10 +00:00
|
|
|
assert len( result[ u"notebooks" ] ) == 1
|
2008-08-19 22:05:40 +00:00
|
|
|
notebook = [ notebook for notebook in result[ u"notebooks" ] if notebook.object_id == self.notebook.object_id ][ 0 ]
|
|
|
|
assert notebook.object_id == self.notebook.object_id
|
|
|
|
assert notebook.name == self.notebook.name
|
2008-10-24 18:51:19 +00:00
|
|
|
assert notebook.read_write == Notebook.READ_WRITE
|
2008-08-19 22:05:40 +00:00
|
|
|
assert notebook.owner == True
|
2008-01-10 08:33:19 +00:00
|
|
|
|
|
|
|
rate_plan = result[ u"rate_plan" ]
|
|
|
|
assert rate_plan
|
|
|
|
assert rate_plan[ u"name" ] == u"super"
|
2008-02-23 23:57:05 +00:00
|
|
|
assert rate_plan[ u"storage_quota_bytes" ] == 1337 * 10
|
2008-01-10 08:33:19 +00:00
|
|
|
|
2008-03-22 04:01:21 +00:00
|
|
|
assert result[ u"first_notebook" ].object_id == self.notebook.object_id
|
|
|
|
assert result[ u"rate_plans" ] == self.settings[ u"global" ].get( u"luminotes.rate_plans", [] )
|
|
|
|
assert result[ u"unsubscribe_button" ] == self.settings[ u"global" ].get( u"luminotes.unsubscribe_button" )
|
2008-01-10 08:33:19 +00:00
|
|
|
|
2008-03-22 04:01:21 +00:00
|
|
|
def upgrade( self ):
|
|
|
|
result = self.http_get( "/upgrade" )
|
2008-01-10 08:33:19 +00:00
|
|
|
|
2008-03-22 04:01:21 +00:00
|
|
|
assert result[ u"redirect" ] == u"/pricing"
|
2008-01-10 08:33:19 +00:00
|
|
|
|
2007-07-16 20:22:38 +00:00
|
|
|
def test_next_id( self ):
|
|
|
|
result = self.http_get( "/next_id" )
|
|
|
|
|
|
|
|
assert result.get( "next_id" )
|
|
|
|
|
|
|
|
result = self.http_get( "/next_id" )
|
|
|
|
|
|
|
|
assert result.get( "next_id" )
|
|
|
|
|
2008-08-15 22:00:16 +00:00
|
|
|
def test_ping( self ):
|
|
|
|
result = self.http_get( "/ping" )
|
|
|
|
|
|
|
|
assert result.get( "response" ) == u"pong"
|
|
|
|
|
2008-08-23 01:29:49 +00:00
|
|
|
def test_shutdown( self ):
|
|
|
|
self.settings[ u"global" ][ u"luminotes.allow_shutdown_command" ] = True
|
|
|
|
|
|
|
|
assert cherrypy.server._is_ready() is True
|
|
|
|
result = self.http_get( "/shutdown" )
|
|
|
|
|
|
|
|
assert cherrypy.server._is_ready() is False
|
|
|
|
|
|
|
|
def test_shutdown_disallowed_explicitly( self ):
|
|
|
|
self.settings[ u"global" ][ u"luminotes.allow_shutdown_command" ] = False
|
|
|
|
|
|
|
|
assert cherrypy.server._is_ready() is True
|
|
|
|
result = self.http_get( "/shutdown" )
|
|
|
|
|
|
|
|
assert cherrypy.server._is_ready() is True
|
|
|
|
|
|
|
|
def test_shutdown_disallowed_implicitly( self ):
|
|
|
|
assert cherrypy.server._is_ready() is True
|
|
|
|
result = self.http_get( "/shutdown" )
|
|
|
|
|
|
|
|
assert cherrypy.server._is_ready() is True
|
|
|
|
|
2007-07-16 20:22:38 +00:00
|
|
|
def test_404( self ):
|
|
|
|
result = self.http_get( "/four_oh_four" )
|
|
|
|
|
|
|
|
body = result.get( u"body" )
|
2007-10-17 07:53:42 +00:00
|
|
|
assert body
|
2007-07-16 20:22:38 +00:00
|
|
|
assert len( body ) > 0
|
|
|
|
assert u"404" in body[ 0 ]
|
|
|
|
|
|
|
|
status = result.get( u"status" )
|
|
|
|
assert u"404" in status
|
|
|
|
|
|
|
|
headers = result.get( u"headers" )
|
|
|
|
status = headers.get( u"status" )
|
|
|
|
assert u"404" in status
|
2007-08-02 23:25:57 +00:00
|
|
|
|
|
|
|
def login( self ):
|
|
|
|
result = self.http_post( "/users/login", dict(
|
|
|
|
username = self.username,
|
|
|
|
password = self.password,
|
|
|
|
login_button = u"login",
|
|
|
|
) )
|
|
|
|
self.session_id = result[ u"session_id" ]
|
2007-09-26 23:49:27 +00:00
|
|
|
|
|
|
|
def test_redeem_reset( self ):
|
|
|
|
redeem_reset_id = u"foobarbaz"
|
2007-10-17 07:53:42 +00:00
|
|
|
result = self.http_get( "/r/%s" % redeem_reset_id )
|
2007-09-26 23:49:27 +00:00
|
|
|
|
|
|
|
assert result[ u"redirect" ] == u"/users/redeem_reset/%s" % redeem_reset_id
|
2007-12-18 00:05:13 +00:00
|
|
|
|
|
|
|
def test_redeem_invite( self ):
|
|
|
|
invite_id = u"foobarbaz"
|
|
|
|
result = self.http_get( "/i/%s" % invite_id )
|
|
|
|
|
|
|
|
assert result[ u"redirect" ] == u"/users/redeem_invite/%s" % invite_id
|
2008-09-11 07:36:12 +00:00
|
|
|
|
|
|
|
def test_download_thanks( self ):
|
|
|
|
download_access_id = u"foobarbaz"
|
|
|
|
result = self.http_get( "/d/%s" % download_access_id )
|
|
|
|
|
2008-09-11 23:57:51 +00:00
|
|
|
assert result[ u"redirect" ] == u"/users/thanks_download?access_id=%s" % download_access_id
|