<s> from datetime import datetime <EOL> import django <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from actstream . signals import action <EOL> from actstream . registry import register , unregister <EOL> from actstream . models import Action , actor_stream , model_stream <EOL> from actstream . tests . base import render , ActivityBaseTestCase <EOL> from actstream . settings import USE_JSONFIELD <EOL> from actstream . runtests . testapp . models import Abstract , Unregistered <EOL> class TestAppTests ( ActivityBaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestAppTests , self ) . setUp ( ) <EOL> self . user = self . User . objects . create ( username = '<STR_LIT:test>' ) <EOL> action . send ( self . user , verb = '<STR_LIT>' ) <EOL> def test_accessor ( self ) : <EOL> self . assertEqual ( len ( Action . objects . testfoo ( self . user ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Action . objects . testfoo ( self . user , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) ) , <NUM_LIT:0> ) <EOL> def test_mystream ( self ) : <EOL> self . assertEqual ( len ( self . user . actor_actions . testbar ( '<STR_LIT>' ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( self . user . action_object_actions . testbar ( '<STR_LIT>' ) ) , <NUM_LIT:0> ) <EOL> def test_registration ( self ) : <EOL> instance = Unregistered . objects . create ( name = '<STR_LIT>' ) <EOL> self . assertRaises ( ImproperlyConfigured , actor_stream , instance ) <EOL> register ( Unregistered ) <EOL> self . assertEqual ( actor_stream ( instance ) . count ( ) , <NUM_LIT:0> ) <EOL> self . assertRaises ( RuntimeError , model_stream , Abstract ) <EOL> self . assertRaises ( ImproperlyConfigured , register , Abstract ) <EOL> unregister ( Unregistered ) <EOL> def test_tag_custom_activity_stream ( self ) : <EOL> stream = self . user . actor_actions . testbar ( '<STR_LIT>' ) <EOL> output = render ( '''<STR_LIT>''' , user = self . user ) <EOL> self . assertAllIn ( [ str ( action ) for action in stream ] , output ) <EOL> self . assertEqual ( self . capture ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) [ '<STR_LIT>' ] , <NUM_LIT:1> ) <EOL> def test_customuser ( self ) : <EOL> if django . VERSION [ : <NUM_LIT:2> ] >= ( <NUM_LIT:1> , <NUM_LIT:5> ) : <EOL> from actstream . runtests . testapp . models import MyUser <EOL> self . assertEqual ( self . User , MyUser ) <EOL> self . assertEqual ( self . user . get_full_name ( ) , '<STR_LIT:test>' ) <EOL> if USE_JSONFIELD : <EOL> def test_jsonfield ( self ) : <EOL> action . send ( self . user , verb = '<STR_LIT>' , text = '<STR_LIT>' , tags = [ '<STR_LIT>' ] , <EOL> more_data = { '<STR_LIT>' : self . user . pk } ) <EOL> newaction = Action . objects . filter ( verb = '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( newaction . data [ '<STR_LIT:text>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( newaction . data [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( newaction . data [ '<STR_LIT>' ] , { '<STR_LIT>' : self . user . pk } ) </s>
