Exemple #1
0
    def test_clothes_listing_for_logged_in_user(self):
        """Test list view of clothe objects for logged in user"""
        self.client.force_login(self.user)
        other_user = create_other_user()

        category = sample_category(self.user)

        # Create clothes object with logged_in user
        models.Clothes.objects.create(
            user=self.user,
            name='Lardini shirt Jacket',
            price=35000,
            description='ラルディーニのシャツジャケット',
            brand=sample_brand(self.user),
            sub_category=sample_subcategory(category=category),
            shop=sample_shop(user=self.user),
            purchased=timezone.now(),
        )

        # Create clothes object with other_user
        models.Clothes.objects.create(
            user=other_user,
            name='Gransasso Knit',
            price=22000,
            description='Gransassoのシャツジャケット',
            brand=sample_brand(user=other_user, name='Gransasso'),
            sub_category=sample_subcategory(category=category),
            shop=sample_shop(user=other_user, name='Ships'),
            purchased=timezone.now(),
        )
        response = self.client.get(reverse('clothes_list_home'))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Lardini')
        self.assertTemplateUsed(response, 'home.html')
        self.assertEqual(len(response.context['clothes_list']), 1)
Exemple #2
0
 def test_shop_listing_for_logged_in_user(self):
     """Test list view of Shop objects for logged in user"""
     self.client.force_login(self.user)
     other_user = create_other_user()
     # Create shop object with logged_in user
     sample_shop(self.user)
     # Create shop object with other_user
     sample_shop(user=other_user, name='Ships')
     response = self.client.get(reverse('clothes:shop_list'))
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, 'Beams')
     self.assertTemplateUsed(response, 'shop/shop_list.html')
     # Only shop created by logged_in_user is in the list
     self.assertEqual(len(response.context['shop_list']), 1)
Exemple #3
0
 def test_shop_clothes_listing_for_logged_out_user(self):
     """Test for logged_out_user to access to shop's clothes list view"""
     shop = sample_shop(self.user)
     response = self.client.get(
         reverse('clothes:shop_clothes', kwargs={'slug': shop.slug}))
     self.assertEqual(response.status_code, 302)
     self.assertRedirects(
         response, '%s?next=/clothes/shop/%s/' %
         (reverse('account_login'), shop.slug))
     response = self.client.get('%s?next=/clothes/shop/%s/' %
                                (reverse('account_login'), shop.slug))
     self.assertContains(response, 'ログイン')
Exemple #4
0
    def test_brand_clothes_listing_for_logged_in_user(self):
        """Test listing of clothes of a brand for logged in user"""
        category = sample_category(self.user)
        brand = sample_brand(self.user, name='Lardini')
        self.client.force_login(self.user)
        other_user = create_other_user()

        # Create clothe object with logged_in user
        models.Clothes.objects.create(
            user=self.user,
            name='Lardini shirt Jacket',
            price=35000,
            description='ラルディーニのシャツジャケット',
            brand=brand,
            sub_category=sample_subcategory(category=category),
            shop=sample_shop(self.user),
            purchased=timezone.now(),
        )

        # Create clothe object with other_user
        models.Clothes.objects.create(
            user=other_user,
            name='Gransasso Knit',
            price=22000,
            description='Gransassoのシャツジャケット',
            brand=sample_brand(user=other_user, name='Gransasso'),
            sub_category=sample_subcategory(category=category),
            shop=sample_shop(other_user, name='ModernBlue'),
            purchased=timezone.now(),
        )
        response = self.client.get(
            reverse('clothes:brand_clothes',
                    kwargs={
                        'id': brand.id,
                        'slug': brand.slug
                    }))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Lardini shirt Jacket')
        self.assertTemplateUsed(response, 'brand/brand_clothes_list.html')
        self.assertEqual(len(response.context['brand_clothes_list']), 1)
Exemple #5
0
    def test_search_clothes_by_shop_name(self):
        """Test returning clothes with specific shop name"""
        self.client.force_login(self.user)

        category = sample_category(self.user)

        # Create clothes object to be included in search result
        clothes1 = models.Clothes.objects.create(
            user=self.user,
            name='YCHAI ワンウォッシュコットンストレッチデニムジーンズ「ROBUSTO',
            price=35000,
            description='YPU004-2DS0001A サイズ31 ウエスト82 股上28 股下73 ワタリ31 裾幅18.8',
            brand=sample_brand(self.user, name='YCHAI'),
            sub_category=sample_subcategory(category=category),
            shop=sample_shop(user=self.user, name='Beams'),
            purchased=timezone.now(),
        )

        # Create another clothes object not to be included in search result
        clothes2 = models.Clothes.objects.create(
            user=self.user,
            name='Zanoneタートルネック',
            price=35000,
            description='Zanoneのタートルネック',
            brand=sample_brand(self.user, name='ZANONE'),
            sub_category=sample_subcategory(category=category),
            shop=sample_shop(user=self.user, name='Ships'),
            purchased=timezone.now(),
        )
        response = (self.client.get(
            "%s?q=%s" %
            (reverse('clothes:search_results'), clothes1.shop.name)))
        self.assertContains(response, clothes1.brand)
        self.assertContains(response, clothes1.name)
        self.assertNotContains(response, clothes2.name)
        self.assertNotContains(response, clothes2.brand)
        self.assertEqual(len(response.context['clothes_list']), 1)
        self.assertTemplateUsed(response,
                                'clothes/clothes_search_results.html')
Exemple #6
0
    def test_search_clothes_by_brand_name(self):
        """Test returning clothes with specific brand name"""
        self.client.force_login(self.user)

        category = sample_category(self.user)

        # Create clothes object to be included in search result
        clothes1 = models.Clothes.objects.create(
            user=self.user,
            name='Lardini shirt Jacket',
            price=35000,
            description='ラルディーニのシャツジャケット',
            brand=sample_brand(self.user, name='LARDINI'),
            sub_category=sample_subcategory(category=category),
            shop=sample_shop(user=self.user),
            purchased=timezone.now(),
        )

        # Create another clothes object not to be included in search result
        clothes2 = models.Clothes.objects.create(
            user=self.user,
            name='Zanoneタートルネック',
            price=35000,
            description='Zanoneのタートルネック',
            brand=sample_brand(self.user, name='ZANONE'),
            sub_category=sample_subcategory(category=category),
            shop=sample_shop(user=self.user, name='Ships'),
            purchased=timezone.now(),
        )
        response = (self.client.get(
            "%s?q=%s" %
            (reverse('clothes:search_results'), clothes1.brand.name)))
        self.assertContains(response, clothes1.brand)
        self.assertContains(response, clothes1.name)
        self.assertNotContains(response, clothes2.name)
        self.assertNotContains(response, clothes2.brand)
        self.assertEqual(len(response.context['clothes_list']), 1)
        self.assertTemplateUsed(response,
                                'clothes/clothes_search_results.html')
Exemple #7
0
    def test_clothes_detail_view(self):
        """Test detail view for clothes"""
        self.client.force_login(self.user)

        category = sample_category(self.user)

        # Create clothes object with logged_in user
        self.clothes = models.Clothes.objects.create(
            user=self.user,
            name='Lardini shirt Jacket',
            price=35000,
            description='ラルディーニのシャツジャケット',
            brand=sample_brand(self.user),
            sub_category=sample_subcategory(category=category),
            shop=sample_shop(user=self.user),
            purchased=timezone.now(),
        )
        response = self.client.get(self.clothes.get_absolute_url())
        no_response = self.client.get('/clothes/19/')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(no_response.status_code, 404)
        self.assertContains(response, 'Lardini shirt Jacket')
        self.assertContains(response, 'ラルディーニのシャツジャケット')
        self.assertTemplateUsed(response, 'clothes/clothes_detail.html')