Ejemplo n.º 1
0
class PitchTest(unittest.TestCase):
    '''
    Test Class to test the behaviour of the Movie class
    '''

    def setUp(self):
        '''
        Set up method that will run before every Test
        '''

        self.user = User(username = '******', password = '******', email = '*****@*****.**')
        self.new_comment = Comment(comment = 'comment', pitch_id = 1, user_id=self.user)
        self.new_pitch = Pitch(id=1, title="Pitch", body='pitches',category='Interview',writer = self.user,comment = self.new_comment)

    def tearDown(self):
        Pitch.query.delete()
        User.query.delete()

    def test_variables(self):
        self.assertEquals(self.new_pitch.id,1)
        self.assertEquals(self.new_pitch.title,'Pitch')
        self.assertEquals(self.new_pitch.body,'pitches')
        self.assertEquals(self.new_pitch.category,"Interview")
        self.assertEquals(self.new_pitch.writer,self.user)
        self.assertEquals(self.new_pitch.comment,self.new_comment)

    def test_save_pitch(self):
        self.new_pitch.save_pitch()
        self.assertTrue(len(Pitch.query.all())>0)

    def test_get_pitch(self):

        self.new_pitch.save_pitch()
        get_pitches = Pitch.get_pitch(1)
        self.assertTrue(len(get_pitches) == 1)
Ejemplo n.º 2
0
    def setUp(self):
        '''
        Set up method that will run before every Test
        '''

        self.user = User(username = '******', password = '******', email = '*****@*****.**')
        self.new_comment = Comment(comment = 'comment', pitch_id = 1, user_id=self.user)
        self.new_pitch = Pitch(id=1, title="Pitch", body='pitches',category='Interview',writer = self.user,comment = self.new_comment)
Ejemplo n.º 3
0
 def setUp(self):
     self.user_fiona = User(username='******',
                            password='******',
                            email='*****@*****.**')
     self.new_pitch = Pitch(id=1,
                            pitch_title='Test',
                            pitch_content='This is a test pitch',
                            category="interview",
                            user=self.user_fiona,
                            likes=0,
                            dislikes=0)
     self.new_comment = Comment(id=1,
                                comment='Test comment',
                                user=self.user_fiona,
                                pitch=self.new_pitch)
Ejemplo n.º 4
0
 def setUp(self):
     self.user_faith = User(username='******',
                            password='******',
                            email='*****@*****.**')
     self.new_pitch = Pitch(id=1,
                            title='Test',
                            description='This is a test pitch',
                            category="interview",
                            user=self.user_faith,
                            upvotes=0,
                            downvotes=0)
     self.new_comment = Comment(id=1,
                                content='Test comment',
                                user=self.user_faith,
                                pitch=self.new_pitch)
Ejemplo n.º 5
0
 def setUp(self):
     self.user_Trial = User(username='******',
                            password='******',
                            email='*****@*****.**')
     self.new_pitch = Pitch(id=1,
                            title='Test',
                            content='This is a test pitch',
                            category="interview",
                            user=self.user_Trial,
                            likes=0,
                            dislikes=0)
     self.new_comment = Comment(id=1,
                                comment='Test comment',
                                user_id=self.user_Trial,
                                pitch_id=self.new_pitch)
Ejemplo n.º 6
0
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        flash('Your post has been created!','success')
        hashtag=''
        hashtags= form.content.data
        print(hashtags)
        newstr= hashtags.split()
        for char in newstr:
            if char.startswith("#"):
                hashtag=char.strip("#")
                print(hashtag)
                post = Pitch(title = form.title.data, content= form.content.data, author = current_user,hashtags=hashtag)
                db.session.add(post)
                db.session.commit()
                return redirect(url_for('main.home'))
        
    return render_template('create_post.html', title='New Post',form=form,legend='New Post') 
Ejemplo n.º 7
0
    def test_get_pitch(self):

        self.new_pitch.save_pitch()
        get_pitches = Pitch.get_pitch(1)
        self.assertTrue(len(get_pitches) == 1)