<s> """<STR_LIT>""" <EOL> from django . test import TestCase <EOL> from django . contrib . auth import get_user_model <EOL> from fabric_bolt . projects import models <EOL> from fabric_bolt . web_hooks import models as hook_models <EOL> from fabric_bolt . web_hooks import forms <EOL> User = get_user_model ( ) <EOL> class TestHooksForms ( TestCase ) : <EOL> project_type = None <EOL> project = None <EOL> stage = None <EOL> configuration = None <EOL> task = None <EOL> deployment = None <EOL> def setUp ( self ) : <EOL> password = '<STR_LIT>' <EOL> self . user = User . objects . create_superuser ( email = '<STR_LIT>' , password = password ) <EOL> self . client . login ( email = self . user . email , password = password ) <EOL> self . _create_project ( ) <EOL> def _create_project ( self ) : <EOL> project = models . Project ( ) <EOL> project . name = '<STR_LIT>' <EOL> project . description = '<STR_LIT>' <EOL> project . save ( ) <EOL> stage = models . Stage ( ) <EOL> stage . project = project <EOL> stage . name = '<STR_LIT>' <EOL> stage . save ( ) <EOL> self . stage = stage <EOL> configuration = models . Configuration ( ) <EOL> configuration . project = project <EOL> configuration . stage = stage <EOL> configuration . key = '<STR_LIT>' <EOL> configuration . value = '<STR_LIT>' <EOL> configuration . prompt_me_for_input = True <EOL> configuration . save ( ) <EOL> self . configuration = configuration <EOL> task = models . Task ( ) <EOL> task . name = '<STR_LIT>' <EOL> task . save ( ) <EOL> self . task = task <EOL> deployment = models . Deployment ( ) <EOL> deployment . user = self . user <EOL> deployment . stage = stage <EOL> deployment . comments = '<STR_LIT>' <EOL> deployment . output = '<STR_LIT>' <EOL> deployment . task = task <EOL> deployment . save ( ) <EOL> hook = hook_models . Hook ( ) <EOL> hook . url = '<STR_LIT>' <EOL> hook . save ( ) <EOL> project_hook = hook_models . Hook ( ) <EOL> project_hook . url = '<STR_LIT>' <EOL> project_hook . project = project <EOL> project_hook . save ( ) <EOL> self . deployment = deployment <EOL> self . hook = hook <EOL> self . project_hook = project_hook <EOL> self . project = project <EOL> def test_hook_create_form ( self ) : <EOL> hook_form = forms . HookCreateForm ( data = { '<STR_LIT>' : self . project . pk , '<STR_LIT:url>' : '<STR_LIT>' } ) <EOL> hook_form . save ( ) <EOL> def test_hook_create_form_clean_project ( self ) : <EOL> hook_form = forms . HookCreateForm ( data = { '<STR_LIT>' : self . project . pk , '<STR_LIT:url>' : '<STR_LIT>' } ) <EOL> hook_form . cleaned_data = { '<STR_LIT>' : self . project . pk } <EOL> p = hook_form . clean_project ( ) <EOL> self . assertEqual ( self . project . pk , p . pk ) <EOL> def test_hook_create_form_clean_project_none ( self ) : <EOL> hook_form = forms . HookCreateForm ( data = { '<STR_LIT>' : self . project . pk , '<STR_LIT:url>' : '<STR_LIT>' } ) <EOL> hook_form . cleaned_data = { '<STR_LIT>' : None } <EOL> p = hook_form . clean_project ( ) <EOL> self . assertEqual ( p , None ) <EOL> def test_hook_update_form ( self ) : <EOL> hook_form = forms . HookUpdateForm ( instance = self . project , data = { '<STR_LIT>' : self . project . pk , '<STR_LIT:url>' : '<STR_LIT>' } ) <EOL> hook_form . is_valid ( ) <EOL> hook_form . save ( ) </s>
