<s> from __future__ import unicode_literals <EOL> import os <EOL> import shutil <EOL> import json <EOL> from memex . test_utils . unit_test_utils import UnitTestSkeleton , form_errors , get_object <EOL> from django . test import TestCase <EOL> from django . core . files . uploadedfile import SimpleUploadedFile <EOL> import pytest <EOL> from apps . crawl_space . forms import AddCrawlForm <EOL> from apps . crawl_space . models import Crawl , CrawlModel <EOL> from base . models import Project , SeedsList , alphanumeric_validator <EOL> def assert_form_errors ( response , * errors ) : <EOL> """<STR_LIT>""" <EOL> efe = expected_form_errors = set ( errors ) <EOL> assert set ( form_errors ( response ) . keys ( ) ) - efe == set ( ) <EOL> class TestViews ( UnitTestSkeleton ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( TestViews , cls ) . setUpClass ( ) <EOL> cls . test_project = Project ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" <EOL> ) <EOL> cls . test_project . save ( ) <EOL> cls . test_seeds_list = SeedsList ( <EOL> name = "<STR_LIT>" , <EOL> seeds = json . dumps ( [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] ) , <EOL> ) <EOL> cls . test_seeds_list . save ( ) <EOL> cls . test_crawl = Crawl ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> crawler = "<STR_LIT>" , <EOL> config = "<STR_LIT>" , <EOL> project = cls . test_project , <EOL> seeds_object = cls . test_seeds_list <EOL> ) <EOL> cls . test_crawl . save ( ) <EOL> @ classmethod <EOL> def get_seeds ( self ) : <EOL> """<STR_LIT>""" <EOL> return SimpleUploadedFile ( '<STR_LIT>' , bytes ( '<STR_LIT>' ) , '<STR_LIT:utf-8>' ) <EOL> @ property <EOL> def crawl_slugs ( self ) : <EOL> """<STR_LIT>""" <EOL> return dict ( slugs = dict ( <EOL> project_slug = "<STR_LIT:test>" , <EOL> crawl_slug = "<STR_LIT>" ) ) <EOL> def test_crawl_delete ( self ) : <EOL> response = self . post ( '<STR_LIT>' , <EOL> ** self . crawl_slugs ) <EOL> assert '<STR_LIT>' in response . template_name </s>
