コード例 #1
0
 def test_that_del_line_deletes_line(self):
     from swaglyrics_backend.issue_maker import del_line
     song = "Supersonics"
     artist = "Caravan Palace"
     generate_fake_unsupported()
     del_line(song, artist)
     with open('unsupported.txt', 'r') as f:
         lines = f.readlines()
         assert not (song + " by " + artist in lines)
コード例 #2
0
 def test_that_delete_line_deletes_line_from_master_unsupported(self):
     from swaglyrics_backend.issue_maker import app
     with app.test_client() as c:
         generate_fake_unsupported()
         response = c.post('/delete_unsupported',
                           data={
                               'auth': '',
                               'song': 'Supersonics',
                               'artist': 'Caravan Palace'
                           })
         assert response.data == b"Removed 1 instances of Supersonics by Caravan " \
                                 b"Palace from unsupported.txt successfully."
コード例 #3
0
 def test_that_add_stripper_adds_stripper(self, app_mock):
     """
     This test doesn't test database behaviour! Only dealing with unsupported and parsing request
     """
     from swaglyrics_backend.issue_maker import app
     with app.test_client() as c:
         generate_fake_unsupported()
         resp = c.post('/add_stripper',
                       data={
                           'auth': '',
                           'song': 'Miracle',
                           'artist': 'Caravan Palace',
                           'stripper': 'Caravan-palace-miracle'
                       })
         assert b"Added stripper for Miracle by Caravan Palace to server database successfully, " \
                b"deleted 1 instances from unsupported.txt" == resp.data
コード例 #4
0
    def test_update_unsupported(self):
        from swaglyrics import __version__
        from swaglyrics_backend.issue_maker import app, limiter
        with app.test_client() as c:
            app.config['TESTING'] = True
            limiter.enabled = False  # disable rate limiting
            generate_fake_unsupported()
            # fix soon
            # self.assertEqual(
            #     update(), 'Please update SwagLyrics to the latest version to get better support :)')

            resp = c.post('/unsupported',
                          data={
                              'version': str(__version__),
                              'song': 'Miracle',
                              'artist': 'Caravan Palace'
                          })
            # Test correct output given song and artist that exist in unsupported.txt
            assert resp.data == b"Issue already exists on the GitHub repo. " \
                                b"\nhttps://github.com/SwagLyrics/SwagLyrics-For-Spotify/issues"
コード例 #5
0
    def test_unsupported_issue_making_error(self, fake_issue, fake_check,
                                            another_fake_check):
        from swaglyrics_backend.issue_maker import app, limiter
        fake_issue.return_value = {
            "status_code": 500,  # error
            "link": ""
        }
        with app.test_client() as c:
            app.config['TESTING'] = True
            limiter.enabled = False  # disable rate limiting
            generate_fake_unsupported()
            resp = c.post('/unsupported',
                          data={
                              'version': '1.2.0',
                              'song': "purple.laces [string%@*]",
                              'artist': 'lost spaces'
                          })
        with open('unsupported.txt') as f:
            data = f.readlines()

        assert "purple.laces [string%@*] by lost spaces\n" in data
        assert resp.data == b"Logged purple.laces [string%@*] by lost spaces in the server."
コード例 #6
0
 def test_that_master_unsupported_reads_data(self):
     from swaglyrics_backend.issue_maker import app
     with app.test_client() as c:
         generate_fake_unsupported()
         req = c.get('/master_unsupported')
         assert req.response is not None