<s> import unittest <EOL> from django . core . urlresolvers import reverse <EOL> from guardian . shortcuts import assign_perm , remove_perm <EOL> from onadata . apps . main . tests . test_base import TestBase <EOL> from onadata . apps . viewer . views import data_view <EOL> class TestDataView ( TestBase ) : <EOL> def setUp ( self ) : <EOL> TestBase . setUp ( self ) <EOL> self . _create_user_and_login ( ) <EOL> self . _publish_transportation_form_and_submit_instance ( ) <EOL> self . url = reverse ( data_view , kwargs = { <EOL> '<STR_LIT:username>' : self . user . username , <EOL> '<STR_LIT>' : self . xform . id_string <EOL> } ) <EOL> def test_data_view ( self ) : <EOL> response = self . client . get ( self . url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> @ unittest . skip ( '<STR_LIT>' ) <EOL> def test_data_view_with_username_and_id_string_in_uppercase ( self ) : <EOL> url = reverse ( data_view , kwargs = { <EOL> '<STR_LIT:username>' : self . user . username . upper ( ) , <EOL> '<STR_LIT>' : self . xform . id_string . upper ( ) <EOL> } ) <EOL> response = self . client . get ( url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_restrict_for_anon ( self ) : <EOL> response = self . anon . get ( self . url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_restrict_for_not_owner ( self ) : <EOL> self . _create_user_and_login ( '<STR_LIT>' ) <EOL> response = self . client . get ( self . url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_allow_if_shared ( self ) : <EOL> self . xform . shared_data = True <EOL> self . xform . save ( ) <EOL> response = self . anon . get ( self . url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_allow_if_user_given_permission ( self ) : <EOL> self . _create_user_and_login ( '<STR_LIT>' ) <EOL> assign_perm ( '<STR_LIT>' , self . user , self . xform ) <EOL> response = self . client . get ( self . url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_disallow_if_user_permission_revoked ( self ) : <EOL> self . _create_user_and_login ( '<STR_LIT>' ) <EOL> assign_perm ( '<STR_LIT>' , self . user , self . xform ) <EOL> response = self . client . get ( self . url ) <EOL> remove_perm ( '<STR_LIT>' , self . user , self . xform ) <EOL> response = self . client . get ( self . url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) </s>
