Beispiel #1
0
    def manage(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "settings")
        self.driver.find_element_by_id("new password").send_keys("pas")
        self.driver.find_element_by_id("new password confirm").send_keys("pas")

        assert self.user.verify_password("pas")
Beispiel #2
0
    def manage(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "settings")
        self.driver.find_element_by_id("new password").send_keys("pas")
        self.driver.find_element_by_id("new password confirm").send_keys("pas")

        assert self.user.verify_password("pas")
Beispiel #3
0
    def friend(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_friend")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id,
                                       b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id,
                                       a_id=self.friend.id).first()

        assert not test1 or not test2

        test = Follow.query.filter_by(requester_id=self.user.id,
                                      requestee_id=self.friend.id).first()

        assert test

        self.driver.find_element_by_id("name").send_keys("test_friend")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_user")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id,
                                       b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id,
                                       a_id=self.friend.id).first()

        assert test1 or test2
Beispiel #4
0
    def friend(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_friend")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id, b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id, a_id=self.friend.id).first()

        assert not test1 or not test2

        test = Follow.query.filter_by(requester_id=self.user.id, requestee_id=self.friend.id).first()

        assert test

        self.driver.find_element_by_id("name").send_keys("test_friend")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_user")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id, b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id, a_id=self.friend.id).first()

        assert test1 or test2
Beispiel #5
0
    def post(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        db.session.add(self.user)
        db.session.commit()

        assert self.user in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.find_element_by_id("post_title").send_keys("This is title")
        self.driver.find_element_by_id("post_body").send_keys("This is a post")
        self.driver.find_element_by_id("post_submit").click()

        test = Post.query.filter_by(title="This is a title").first()

        assert test
Beispiel #6
0
    def comment(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        db.session.add(self.user)
        db.session.commit()

        assert self.user in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.find_element_by_id("post_title").click()
        self.driver.find_element_by_id("comment_box").send_keys("THIS IS A COMMENT")
        self.driver.find_element_by_id("comment_submit").click()

        test = Comment.query.filter_by(body="THIS IS A COMMENT").first()
        assert test
Beispiel #7
0
class StartingTestCase(unittest.TestCase):
    def setUp(self):
        self.app = testing_app
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()

        self.driver = webdriver.PhantomJS()
        self.baseURL = "http://localhost:5000/"

        self.driver.set_window_size(1124, 850)

    def tearDown(self):
        self.driver.quit()
        db.session.remove()
        db.drop_all()
        self.app_context.pop()

    # --------------------------------------------------------------------------
    # User/profile and Post tests
    # --------------------------------------------------------------------------

    # As an author, I want to befriend local authors
    def test_befriend(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_friend")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        self.driver.find_element_by_id("name").send_keys("test_friend")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_user")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id,
                                       b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id,
                                       a_id=self.friend.id).first()

        assert test1 or test2

    # As an author, I want un-befriend local and remote authors
    def unfriend(self):
        test_befriend()
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_friend")
        self.driver.find_element_by_id("unfollow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id,
                                       b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id,
                                       a_id=self.friend.id).first()

        assert not test1 or not test2

    # As an author, I want to be able to use my web-browser to manage my profile
    def manage(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "settings")
        self.driver.find_element_by_id("new password").send_keys("pas")
        self.driver.find_element_by_id("new password confirm").send_keys("pas")

        assert self.user.verify_password("pas")

    # As an author, When I befriend someone it follows them, only when the other authors befriends me do I count as a real friend.
    def friend(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_friend")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id,
                                       b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id,
                                       a_id=self.friend.id).first()

        assert not test1 or not test2

        test = Follow.query.filter_by(requester_id=self.user.id,
                                      requestee_id=self.friend.id).first()

        assert test

        self.driver.find_element_by_id("name").send_keys("test_friend")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_user")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id,
                                       b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id,
                                       a_id=self.friend.id).first()

        assert test1 or test2

    # test comments
    def comment(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        db.session.add(self.user)
        db.session.commit()

        assert self.user in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.find_element_by_id("post_title").click()
        self.driver.find_element_by_id("comment_box").send_keys(
            "THIS IS A COMMENT")
        self.driver.find_element_by_id("comment_submit").click()

        test = Comment.query.filter_by(body="THIS IS A COMMENT").first()
        assert test

    # test posts
    def post(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        db.session.add(self.user)
        db.session.commit()

        assert self.user in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.find_element_by_id("post_title").send_keys("This is title")
        self.driver.find_element_by_id("post_body").send_keys("This is a post")
        self.driver.find_element_by_id("post_submit").click()

        test = Post.query.filter_by(title="This is a title").first()

        assert test
Beispiel #8
0
class StartingTestCase(unittest.TestCase):
    def setUp(self):
        self.app = testing_app
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()

        self.driver = webdriver.PhantomJS()
        self.baseURL = "http://localhost:5000/"

        self.driver.set_window_size(1124, 850)

    def tearDown(self):
        self.driver.quit()
        db.session.remove()
        db.drop_all()
        self.app_context.pop()       

    # --------------------------------------------------------------------------
    # User/profile and Post tests
    # --------------------------------------------------------------------------

    # As an author, I want to befriend local authors
    def test_befriend(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_friend")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        self.driver.find_element_by_id("name").send_keys("test_friend")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_user")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id, b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id, a_id=self.friend.id).first()

        assert test1 or test2

    # As an author, I want un-befriend local and remote authors
    def unfriend(self):
        test_befriend();
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_friend")
        self.driver.find_element_by_id("unfollow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id, b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id, a_id=self.friend.id).first()

        assert not test1 or not test2

    # As an author, I want to be able to use my web-browser to manage my profile
    def manage(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "settings")
        self.driver.find_element_by_id("new password").send_keys("pas")
        self.driver.find_element_by_id("new password confirm").send_keys("pas")

        assert self.user.verify_password("pas")

    # As an author, When I befriend someone it follows them, only when the other authors befriends me do I count as a real friend.
    def friend(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        self.friend = User(username='******')
        self.friend.set_password('pass')
        self.friend.set_id()

        db.session.add(self.user)
        db.session.add(self.friend)
        db.session.commit()

        assert self.user in db.session
        assert self.friend in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_friend")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id, b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id, a_id=self.friend.id).first()

        assert not test1 or not test2

        test = Follow.query.filter_by(requester_id=self.user.id, requestee_id=self.friend.id).first()

        assert test

        self.driver.find_element_by_id("name").send_keys("test_friend")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.get(self.baseURL + "user/test_user")
        self.driver.find_element_by_id("follow_button").click()
        self.driver.get(self.baseURL + "/logout")

        test1 = Friend.query.filter_by(a_id=self.user.id, b_id=self.friend.id).first()
        test2 = Friend.query.filter_by(b_id=self.user.id, a_id=self.friend.id).first()

        assert test1 or test2

    # test comments
    def comment(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        db.session.add(self.user)
        db.session.commit()

        assert self.user in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.find_element_by_id("post_title").click()
        self.driver.find_element_by_id("comment_box").send_keys("THIS IS A COMMENT")
        self.driver.find_element_by_id("comment_submit").click()

        test = Comment.query.filter_by(body="THIS IS A COMMENT").first()
        assert test

    # test posts
    def post(self):
        self.user = User(username='******')
        self.user.set_password('pass')
        self.user.set_id()

        db.session.add(self.user)
        db.session.commit()

        assert self.user in db.session
        driver.save_screenshot('test.png')

        self.driver.get(self.baseURL)
        self.driver.find_element_by_id("name").send_keys("test_user")
        self.driver.find_element_by_id("password").send_keys("pass")
        self.driver.find_element_by_id("submit").click()

        self.driver.find_element_by_id("post_title").send_keys("This is title")
        self.driver.find_element_by_id("post_body").send_keys("This is a post")
        self.driver.find_element_by_id("post_submit").click()

        test = Post.query.filter_by(title="This is a title").first()

        assert test