<s> from __future__ import unicode_literals <EOL> from memex . test_utils . unit_test_utils import UnitTestSkeleton , form_errors <EOL> from django . test import TestCase <EOL> from django . db import IntegrityError <EOL> from django . core . files . uploadedfile import SimpleUploadedFile <EOL> from base . forms import AddProjectForm <EOL> from base . models import Project <EOL> from test_crawl import assert_form_errors <EOL> class TestAddDataModelView ( UnitTestSkeleton ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( TestAddDataModelView , cls ) . setUpClass ( ) <EOL> cls . test_project = Project ( <EOL> name = u"<STR_LIT>" , <EOL> description = "<STR_LIT>" ) <EOL> cls . test_project . save ( ) <EOL> @ property <EOL> def slugs ( self ) : <EOL> return dict ( slugs = dict ( <EOL> project_slug = "<STR_LIT>" ) ) <EOL> def get_model_file ( self ) : <EOL> return SimpleUploadedFile ( '<STR_LIT>' , bytes ( '<STR_LIT>' ) , '<STR_LIT:utf-8>' ) <EOL> def get_features_file ( self ) : <EOL> return SimpleUploadedFile ( '<STR_LIT>' , bytes ( '<STR_LIT>' ) , '<STR_LIT:utf-8>' ) <EOL> def test_add_model_page ( self ) : <EOL> response = self . get ( '<STR_LIT>' , ** self . slugs ) <EOL> assert '<STR_LIT>' in response . template_name <EOL> def test_add_model_no_data ( self ) : <EOL> response = self . post ( '<STR_LIT>' , ** self . slugs ) <EOL> assert_form_errors ( response , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_add_model_no_name ( self ) : <EOL> response = self . post ( '<STR_LIT>' , <EOL> { <EOL> '<STR_LIT>' : self . get_model_file ( ) , <EOL> '<STR_LIT>' : self . get_features_file ( ) , <EOL> } , <EOL> ** self . slugs ) <EOL> assert_form_errors ( response , '<STR_LIT:name>' ) <EOL> def test_add_model_no_model ( self ) : <EOL> response = self . post ( '<STR_LIT>' , <EOL> { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . get_features_file ( ) , <EOL> } , <EOL> ** self . slugs ) <EOL> assert_form_errors ( response , '<STR_LIT>' ) <EOL> def test_add_model_no_features ( self ) : <EOL> response = self . post ( '<STR_LIT>' , <EOL> { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . get_model_file ( ) , <EOL> } , <EOL> ** self . slugs ) <EOL> assert_form_errors ( response , '<STR_LIT>' ) <EOL> def test_add_model_success ( self ) : <EOL> response = self . post ( '<STR_LIT>' , <EOL> { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . get_model_file ( ) , <EOL> '<STR_LIT>' : self . get_features_file ( ) , <EOL> } , <EOL> ** self . slugs ) </s>
