def test_colection_form(self): """Test for checking colection form. It will insert one Colection from the ColectionForm and check if is accesible via its direct url. """ distributor = create_publisher(name='Forum', nationality='US') editor1 = create_publisher(name='Marvel', nationality='US') name = "The incredible Hulk" subname = "Green Stories" volume = 1 language = "ES" max_numbers = 12 colection_type = 'regular' colection_slug = slugify(name) form_url = '/{}/colections/add/'.format(proj_name) p1_url = '/{}/colections/{}/'.format(proj_name, colection_slug) response = self.client.post( form_url, { 'name': name, 'subname': subname, 'volume': volume, 'language': language, 'max_numbers': max_numbers, 'colection_type': colection_type, 'distributor': distributor, 'editors': editor1, }) response_view = self.client.get(p1_url) self.assertEqual(response.status_code, HTTP_OK_CODE) self.assertEqual(response_view.status_code, HTTP_OK_CODE)
def test_publisher_creation(self): """Test for creating an object from model Publisher.""" p1 = create_publisher(name='Marvel', nationality='US') p2 = create_publisher(name='Forum', nationality='ES') self.assertTrue(isinstance(p1, Publisher)) self.assertTrue(isinstance(p2, Publisher)) self.assertEqual(p1.nationality.name, 'United States of America') self.assertEqual(p2.nationality.name, 'Spain')
def test_publisher_view(self): """Test for checking publisher views.""" p1 = create_publisher(name='DC Comics', nationality='US') p1_url = '/{}/publishers/{}/'.format(proj_name, p1.slug) response = self.client.get(p1_url) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, template_name='comics/publisher.html')
def test_colection_creation(self): """Test for creating an object from model Colection.""" p1 = create_publisher(name='TestPublisher002', nationality='ES') c1 = create_colection(name='Xmen', subname='children of the atom', vol=2, language='ES', distributor_id=p1, colection_type='Regular', max_numbers=50) self.assertTrue(isinstance(c1, Colection)) self.assertEqual(c1.language.name, 'Spain')
def test_colection_missing_comics(self): """ Test for returning missing comics from a collection. A collection can begin in a specific number and have max_numbers So it could be: - from 0..7 (8 numbers) - from 1..12 (12 numbers) - from 12..38 (26 numbers) """ u1 = create_user(username='******') p1 = create_publisher(name='TestPublisher003', nationality='ES') c1 = create_colection(name='Superman', subname='The man of Steel', vol=2, language='ES', distributor_id=p1, colection_type='Regular', max_numbers=8, initial_number=0) c2 = create_colection(name='Flash', subname='Hyper speed', vol=1, language='ES', distributor_id=p1, colection_type='Regular', max_numbers=12, initial_number=1) c3 = create_colection(name='Wonder Woman', subname='Amazing', vol=1, language='ES', distributor_id=p1, colection_type='Regular', max_numbers=26, initial_number=12) c1.complete_colection(user=u1) c2.complete_colection(user=u1) c3.complete_colection(user=u1) missing_list_c1 = c1.get_missing_comics() missing_list_c2 = c2.get_missing_comics() missing_list_c3 = c3.get_missing_comics() self.assertEqual(len(missing_list_c1), 0) self.assertEqual(len(missing_list_c2), 0) self.assertEqual(len(missing_list_c3), 0)
def test_colection_view(self): """Test for checking publisher views.""" p1 = create_publisher(name='TestPublisher009', nationality='ES') c1 = create_colection(name='The Amazing Spiderman', subname='Peter Parker is...', vol=1, language='ES', distributor_id=p1, colection_type='Regular', max_numbers=50) c1_url = '/{}/colections/{}/'.format(proj_name, c1.slug) response = self.client.get(c1_url) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, template_name='comics/colection.html')
def test_comic_creation(self): """Test for creating an object from model Comic.""" p1 = create_publisher(name='TestPublisher002', nationality='US') c1 = create_colection(name='Xmen2', subname='children of the atom', vol=2, language='ES', distributor_id=p1, colection_type='Regular', max_numbers=50) comic = create_comic(title='Return of Colossus', number=10, pages=64, collection=c1) self.assertTrue(isinstance(p1, Publisher)) self.assertTrue(isinstance(c1, Colection)) self.assertTrue(isinstance(comic, Comic)) self.assertEqual(p1.nationality.name, 'United States of America') self.assertEqual(c1.language.name, 'Spain') self.assertEqual(c1.numbers, 1)