Example #1
0
    def test_404_page(self):
        with app.test_client() as client:
            resp = client.get("/notalink")
            html = resp.get_data(as_text=True)

            self.assertEqual(resp.status_code, 404)
            self.assertIn("<p>404: Looks like we", html)
Example #2
0
    def test_home_page(self):
        with app.test_client() as client:
            resp = client.get("/")
            html = resp.get_data(as_text=True)

            self.assertEqual(resp.status_code, 200)
            self.assertIn('<p>What is this Keymix?</p>', html)
Example #3
0
    def test_login(self):
        with app.test_client() as client:
            d = {"username": "******", "password": "******"}
            resp = client.post("/login", data=d, follow_redirects=True)
            html = resp.get_data(as_text=True)

            self.assertEqual(resp.status_code, 200)
            self.assertIn('<p>What is this Keymix?</p>', html)
            self.assertIn(
                '<a class="navbar-item is-pulled-left has-text-success">Welcome back, test1!</a>',
                html)
Example #4
0
    def test_register_render(self):
        with app.test_client() as client:
            resp = client.get("/register")
            html = resp.get_data(as_text=True)

            self.assertEqual(resp.status_code, 200)
            self.assertIn(
                '<label class="label is-small" for="username">Username</label>',
                html)
            self.assertIn(
                '<label class="label is-small" for="password">Password</label>',
                html)
Example #5
0
 def test_logout(self):
     """Tests when user clicks the Logout link"""
     with app.test_client() as client:
         with client.session_transaction() as session:
             session['token'] = 'token'
             session['refresh_token'] = 'refresh_token'
             session['user_id'] = 'user_id'
         user_id = 'user_id'
         self.assertEqual(user_id, session.get('user_id'))
         self.assertEqual(session['user_id'], 'user_id')
         session.clear()
         self.assertNotEqual(user_id, session.get('user_id'))
Example #6
0
    def test_register(self):
        with app.test_client() as client:
            d = {
                "username": "******",
                "password": "******",
                "email": "*****@*****.**",
                "first_name": "testy",
                "last_name": "testman"
            }
            resp = client.post("/register", data=d, follow_redirects=True)
            html = resp.get_data(as_text=True)

            self.assertEqual(resp.status_code, 200)
            self.assertIn('<p>What is this Keymix?</p>', html)
            self.assertIn(
                '<a class="navbar-item is-pulled-left has-text-success">Welcome! Account created successfully!</a>',
                html)
Example #7
0
 def test_seed_parameters(self):
     """Tests seeding based on several seeds including artist, track, genre, and more."""
     with app.test_client() as client:
         client.get('/auth')
         resp = client.post('/seed',
                            data={
                                'artist': '1D3hV1Gke8LLRSn1aymglN',
                                'seed_genre': 'house',
                                'tempo': 128,
                                'danceability': 0.9,
                                'energy': 0.9,
                                'speechiness': 0.9,
                                'acousticness': 0.9,
                                'instrumentalness': 0.9,
                                'liveness': 0.9,
                                'valence': 0.9,
                                'popularity': 1,
                                'loudness': 0.9,
                            },
                            follow_redirects=True)
         html = resp.get_data(as_text=True)
         self.assertIn('https://open.spotify.com/embed/track', html)