示例#1
0
    def test_retrieve_featured_artists(self):

        date_format = '%m/%d/%Y'

        start = datetime.today()
        str_start = start.strftime(date_format)
        #TODO: this would fail in december
        end = datetime(start.year, start.month + 1, 1)
        str_end = end.strftime(date_format)

        for i in range(1, 10):
            user = fixtures.create_user(
                username='******' + str(i), password='******', email='user' + str(i) + '@test.com', first_name='test', last_name='user'
            )

            fa = fixtures.create_featured_artist(
                user_id=user.id, start_date=start, end_date=end, photo='\whatever'
            )

        featured_artists = retrieve_featured_artists(5)
        first_fa_ids = []
        for fa in featured_artists:
            first_fa_ids.append(fa.id)

        self.assertEqual(len(featured_artists), 5)
        self.assertEqual(featured_artists[0].total_imprints, 1)

        next_featured_artists = retrieve_featured_artists(5)
        next_fa_ids = []

        for fa in next_featured_artists:
            next_fa_ids.append(fa.id)

        self.assertNotEqual(first_fa_ids, next_fa_ids)
示例#2
0
    def test_featured_artist_creation(self):
        """
            test creation of an artist model record
        """

        user = fixtures.create_user(
                username='******', password='******', email='*****@*****.**', first_name='test', last_name='user'
        )

        start = datetime.today()
        end = start + timedelta(days=10)

        fa = fixtures.create_featured_artist(
            user_id=user.id, start_date=start, end_date=end, photo='\whatever'
        )


        self.assertTrue(isinstance(fa, FeaturedArtist))
示例#3
0
    def test_index_get(self):
        """
            test a get request to the index view
        """
        for i in range(1, 10):
            user = fixtures.create_user(
                username='******' + str(i), password='******', email='user' + str(i) + '@test.com', first_name='test', last_name='user'
            )

            start = datetime.today()
            end = start + timedelta(days=10)

            fa = fixtures.create_featured_artist(
                user_id=user.id, start_date=start, end_date=end, photo='\whatever'
            )
        url = reverse('home.views.index')
        resp = self.client.get(url)

        self.assertEqual(resp.status_code, 200)
示例#4
0
    def test_get_featured_authenticated_artist_existing_fa(self):
        """
            test a get request as an authenticated artist to the get_featured view with an existing fa
        """

        user = fixtures.create_user(
            username='******', password='******', email='*****@*****.**', first_name='test', last_name='user'
        )
        start = datetime.today()
        end = start + timedelta(days=10)

        fa = fixtures.create_featured_artist(
            user_id=user.id, start_date=start, end_date=end, photo='\whatever'
        )

        self.client.login(username=user.username, password='******')
        s = self.client.session
        s['user_id'] = user.id
        s.save()

        url = reverse("artists.views.get_featured")
        resp = self.client.get(url)

        self.assertEqual(resp.status_code, 302)