<s> from django . test import TestCase <EOL> from localshop . apps . dashboard import forms <EOL> from tests . factories import CredentialFactory , TeamFactory , RepositoryFactory <EOL> class TestAccessControlForm ( TestCase ) : <EOL> def test_save_add ( self ) : <EOL> repository = RepositoryFactory ( ) <EOL> data = { <EOL> '<STR_LIT:label>' : '<STR_LIT:all>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> } <EOL> form = forms . AccessControlForm ( data , repository = repository ) <EOL> assert form . is_valid ( ) <EOL> form . save ( ) <EOL> assert repository . cidr_list . count ( ) == <NUM_LIT:1> <EOL> class TestRepositoryTeamForm ( TestCase ) : <EOL> def test_init ( self ) : <EOL> repository = RepositoryFactory ( ) <EOL> form = forms . RepositoryTeamForm ( repository = repository ) <EOL> def test_save_add ( self ) : <EOL> team = TeamFactory ( ) <EOL> repository = RepositoryFactory ( ) <EOL> data = { <EOL> '<STR_LIT>' : team . pk , <EOL> } <EOL> form = forms . RepositoryTeamForm ( data , repository = repository ) <EOL> assert form . is_valid ( ) <EOL> form . save ( ) <EOL> assert repository . teams . count ( ) == <NUM_LIT:1> <EOL> def test_save_delete ( self ) : <EOL> team = TeamFactory ( ) <EOL> repository = RepositoryFactory ( ) <EOL> repository . teams . add ( team ) <EOL> data = { <EOL> '<STR_LIT>' : team . pk , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> } <EOL> form = forms . RepositoryTeamForm ( data , repository = repository ) <EOL> assert form . is_valid ( ) <EOL> form . save ( ) <EOL> assert repository . teams . count ( ) == <NUM_LIT:0> <EOL> class TestCredentialModelForm ( TestCase ) : <EOL> def test_save_new ( self ) : <EOL> repository = RepositoryFactory ( ) <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> form = forms . CredentialModelForm ( data , repository = repository ) <EOL> assert form . is_valid ( ) <EOL> form . save ( ) <EOL> assert repository . credentials . count ( ) == <NUM_LIT:1> <EOL> credential = repository . credentials . first ( ) <EOL> assert credential . comment == '<STR_LIT>' <EOL> assert credential . allow_upload is False <EOL> assert credential . deactivated is None <EOL> def test_save_new ( self ) : <EOL> repository = RepositoryFactory ( ) <EOL> credential = CredentialFactory ( <EOL> repository = repository , allow_upload = True ) <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> } <EOL> form = forms . CredentialModelForm ( <EOL> data , instance = credential , repository = repository ) <EOL> assert form . is_valid ( ) <EOL> form . save ( ) <EOL> assert repository . credentials . count ( ) == <NUM_LIT:1> <EOL> credential = repository . credentials . first ( ) <EOL> assert credential . comment == '<STR_LIT>' <EOL> assert credential . allow_upload is True <EOL> assert credential . deactivated is not None </s>
