<s> from django . db . models . loading import cache <EOL> cache . get_apps ( ) <EOL> from freenasUI . api . tests . utils import APITestCase <EOL> from freenasUI . account import models <EOL> class UsersResourceTest ( APITestCase ) : <EOL> def test_get_list_unauthorzied ( self ) : <EOL> self . assertHttpUnauthorized ( <EOL> self . client . get ( self . get_api_url ( ) , format = '<STR_LIT>' ) <EOL> ) <EOL> def test_Create ( self ) : <EOL> resp = self . api_client . post ( <EOL> self . get_api_url ( ) , <EOL> format = '<STR_LIT>' , <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ) <EOL> self . assertHttpCreated ( resp ) <EOL> self . assertValidJSON ( resp . content ) <EOL> data = self . deserialize ( resp ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] , False ) <EOL> def test_Retrieve ( self ) : <EOL> obj = models . bsdUsers . objects . create ( <EOL> bsdusr_uid = <NUM_LIT> , <EOL> bsdusr_group = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT> , <EOL> bsdgrp_group = '<STR_LIT>' <EOL> ) , <EOL> bsdusr_username = '<STR_LIT>' , <EOL> bsdusr_shell = '<STR_LIT>' , <EOL> bsdusr_full_name = '<STR_LIT>' , <EOL> ) <EOL> resp = self . api_client . get ( <EOL> self . get_api_url ( ) , <EOL> format = '<STR_LIT>' , <EOL> ) <EOL> self . assertHttpOK ( resp ) <EOL> data = self . deserialize ( resp ) <EOL> self . assertTrue ( { <EOL> u'<STR_LIT:id>' : obj . id , <EOL> u'<STR_LIT>' : <NUM_LIT> , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : <NUM_LIT> , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : False , <EOL> u'<STR_LIT>' : u'<STR_LIT:*>' , <EOL> u'<STR_LIT>' : u'<STR_LIT:*>' , <EOL> u'<STR_LIT>' : False , <EOL> u'<STR_LIT>' : False , <EOL> u'<STR_LIT>' : False , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> } in data ) <EOL> def test_Update ( self ) : <EOL> obj = models . bsdUsers . objects . create ( <EOL> bsdusr_uid = <NUM_LIT> , <EOL> bsdusr_group = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT> , <EOL> bsdgrp_group = '<STR_LIT>' <EOL> ) , <EOL> bsdusr_username = '<STR_LIT>' , <EOL> bsdusr_shell = '<STR_LIT>' , <EOL> bsdusr_full_name = '<STR_LIT>' , <EOL> ) <EOL> resp = self . api_client . put ( <EOL> '<STR_LIT>' % ( self . get_api_url ( ) , obj . id ) , <EOL> format = '<STR_LIT>' , <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ) <EOL> self . assertHttpOK ( resp ) <EOL> data = self . deserialize ( resp ) <EOL> self . assertEqual ( data [ '<STR_LIT:id>' ] , obj . id ) <EOL> def test_Delete ( self ) : <EOL> obj = models . bsdUsers . objects . create ( <EOL> bsdusr_uid = <NUM_LIT> , <EOL> bsdusr_group = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT> , <EOL> bsdgrp_group = '<STR_LIT>' <EOL> ) , <EOL> bsdusr_username = '<STR_LIT>' , <EOL> bsdusr_shell = '<STR_LIT>' , <EOL> bsdusr_full_name = '<STR_LIT>' , <EOL> ) <EOL> resp = self . api_client . delete ( <EOL> '<STR_LIT>' % ( self . get_api_url ( ) , obj . id ) , <EOL> format = '<STR_LIT>' , <EOL> ) <EOL> self . assertHttpAccepted ( resp ) <EOL> def test_Password ( self ) : <EOL> obj = models . bsdUsers . objects . create ( <EOL> bsdusr_uid = <NUM_LIT> , <EOL> bsdusr_group = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT> , <EOL> bsdgrp_group = '<STR_LIT>' <EOL> ) , <EOL> bsdusr_username = '<STR_LIT>' , <EOL> bsdusr_shell = '<STR_LIT>' , <EOL> bsdusr_full_name = '<STR_LIT>' , <EOL> ) <EOL> resp = self . api_client . post ( <EOL> '<STR_LIT>' % ( self . get_api_url ( ) , obj . id ) , <EOL> format = '<STR_LIT>' , <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ) <EOL> self . assertHttpAccepted ( resp ) <EOL> data = self . deserialize ( resp ) <EOL> self . assertEqual ( data [ '<STR_LIT:id>' ] , obj . id ) <EOL> def test_Groups_retrieve ( self ) : <EOL> obj = models . bsdUsers . objects . create ( <EOL> bsdusr_uid = <NUM_LIT> , <EOL> bsdusr_group = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT> , <EOL> bsdgrp_group = '<STR_LIT>' <EOL> ) , <EOL> bsdusr_username = '<STR_LIT>' , <EOL> bsdusr_shell = '<STR_LIT>' , <EOL> bsdusr_full_name = '<STR_LIT>' , <EOL> ) <EOL> group = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT:100> , <EOL> bsdgrp_group = '<STR_LIT>' , <EOL> ) <EOL> models . bsdGroupMembership . objects . create ( <EOL> bsdgrpmember_group = group , <EOL> bsdgrpmember_user = obj , <EOL> ) <EOL> resp = self . api_client . get ( <EOL> '<STR_LIT>' % ( self . get_api_url ( ) , obj . id ) , <EOL> format = '<STR_LIT>' , <EOL> ) <EOL> self . assertHttpOK ( resp ) <EOL> data = self . deserialize ( resp ) <EOL> self . assertEqual ( data , [ "<STR_LIT>" ] ) <EOL> def test_Groups_update ( self ) : <EOL> obj = models . bsdUsers . objects . create ( <EOL> bsdusr_uid = <NUM_LIT> , <EOL> bsdusr_group = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT> , <EOL> bsdgrp_group = '<STR_LIT>' <EOL> ) , <EOL> bsdusr_username = '<STR_LIT>' , <EOL> bsdusr_shell = '<STR_LIT>' , <EOL> bsdusr_full_name = '<STR_LIT>' , <EOL> ) <EOL> models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT:100> , <EOL> bsdgrp_group = '<STR_LIT>' , <EOL> ) <EOL> resp = self . api_client . post ( <EOL> '<STR_LIT>' % ( self . get_api_url ( ) , obj . id ) , <EOL> format = '<STR_LIT>' , <EOL> data = [ '<STR_LIT>' ] , <EOL> ) <EOL> self . assertHttpAccepted ( resp ) <EOL> data = self . deserialize ( resp ) <EOL> self . assertEqual ( data , [ "<STR_LIT>" ] ) <EOL> class GroupsResourceTest ( APITestCase ) : <EOL> def test_get_list_unauthorzied ( self ) : <EOL> self . assertHttpUnauthorized ( <EOL> self . client . get ( self . get_api_url ( ) , format = '<STR_LIT>' ) <EOL> ) <EOL> def test_Create ( self ) : <EOL> resp = self . api_client . post ( <EOL> self . get_api_url ( ) , <EOL> format = '<STR_LIT>' , <EOL> data = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ) <EOL> self . assertHttpCreated ( resp ) <EOL> self . assertValidJSON ( resp . content ) <EOL> data = self . deserialize ( resp ) <EOL> self . assertEqual ( data , { <EOL> '<STR_LIT:id>' : <NUM_LIT:2> , <EOL> u'<STR_LIT>' : False , <EOL> u'<STR_LIT>' : <NUM_LIT> , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : False , <EOL> } ) <EOL> def test_Retrieve ( self ) : <EOL> obj = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT> , <EOL> bsdgrp_group = '<STR_LIT>' , <EOL> ) <EOL> resp = self . api_client . get ( <EOL> self . get_api_url ( ) , <EOL> format = '<STR_LIT>' , <EOL> ) <EOL> self . assertHttpOK ( resp ) <EOL> data = self . deserialize ( resp ) <EOL> self . assertTrue ( { <EOL> u'<STR_LIT:id>' : obj . id , <EOL> u'<STR_LIT>' : False , <EOL> u'<STR_LIT>' : <NUM_LIT> , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : False , <EOL> } in data ) <EOL> def test_Update ( self ) : <EOL> obj = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT> , <EOL> bsdgrp_group = '<STR_LIT>' , <EOL> ) <EOL> resp = self . api_client . put ( <EOL> '<STR_LIT>' % ( self . get_api_url ( ) , obj . id ) , <EOL> format = '<STR_LIT>' , <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ) <EOL> self . assertHttpOK ( resp ) <EOL> data = self . deserialize ( resp ) <EOL> self . assertEqual ( data [ '<STR_LIT:id>' ] , obj . id ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_Delete ( self ) : <EOL> obj = models . bsdGroups . objects . create ( <EOL> bsdgrp_gid = <NUM_LIT> , <EOL> bsdgrp_group = '<STR_LIT>' , <EOL> ) <EOL> resp = self . api_client . delete ( <EOL> '<STR_LIT>' % ( self . get_api_url ( ) , obj . id ) , <EOL> format = '<STR_LIT>' , <EOL> ) <EOL> self . assertHttpAccepted ( resp ) </s>
