<s> import pytest <EOL> from comport . admin . forms import NewDepartmentForm <EOL> from comport . department . models import Department <EOL> @ pytest . mark . usefixtures ( '<STR_LIT>' ) <EOL> class TestNewDepartmentForm : <EOL> def test_validate_success ( self , db ) : <EOL> '''<STR_LIT>''' <EOL> form = NewDepartmentForm ( department_name = "<STR_LIT>" , department_short_name = "<STR_LIT>" ) <EOL> assert form . validate ( ) is True <EOL> def test_department_name_required ( self ) : <EOL> '''<STR_LIT>''' <EOL> form = NewDepartmentForm ( department_name = None , department_short_name = "<STR_LIT>" ) <EOL> assert form . validate ( ) is False <EOL> assert '<STR_LIT>' in form . department_name . errors <EOL> def test_department_short_name_required ( self ) : <EOL> '''<STR_LIT>''' <EOL> form = NewDepartmentForm ( department_name = "<STR_LIT>" , department_short_name = None ) <EOL> assert form . validate ( ) is False <EOL> assert '<STR_LIT>' in form . department_short_name . errors <EOL> def test_department_name_unique_required ( self , db ) : <EOL> '''<STR_LIT>''' <EOL> test_name = "<STR_LIT>" <EOL> test_short_name = "<STR_LIT>" <EOL> Department . create ( name = test_name , short_name = test_short_name ) <EOL> form = NewDepartmentForm ( department_name = test_name , department_short_name = test_short_name ) <EOL> assert form . validate ( ) is False <EOL> assert '<STR_LIT>' . format ( test_name ) in form . department_name . errors <EOL> def test_department_short_name_unique_required ( self , db ) : <EOL> '''<STR_LIT>''' <EOL> test_name = "<STR_LIT>" <EOL> test_short_name = "<STR_LIT>" <EOL> Department . create ( name = test_name , short_name = test_short_name ) <EOL> form = NewDepartmentForm ( department_name = "<STR_LIT>" , department_short_name = test_short_name ) <EOL> assert form . validate ( ) is False <EOL> assert '<STR_LIT>' . format ( test_short_name ) in form . department_short_name . errors </s>
