nithinmurali / pygsheets

Google Sheets Python API v4
https://pygsheets.readthedocs.io/en/latest
Other
1.51k stars 220 forks source link

Improvement the way and environment of testing #526

Open rariyama opened 2 years ago

rariyama commented 2 years ago

Overall

I will offer some ideas about the way and environment of testing. It will improve developer experiences a lot.

Ideas

  1. to create a new command in Makefile which enables developers to test each function. Developer must currently test all functions even if they try to implement just one function.
  2. to make it possible to use the developer's credential instead of using default credential. If they would like to confirm the action of functions in pipeline, they must overwrite pygsheettest_service_account.json by their credential and also overwrite these classes by local spreadsheet. for example.

    # @pytest.mark.skip()
    class TestWorkSheet(object):
    def setup_class(self):
        title = test_config.get('Spreadsheet', 'title') + PYTHON_VERSION
        self.spreadsheet = pygsheet_client.create(title)
        self.worksheet = self.spreadsheet.worksheet()
    
        sp = self.python_client.open_by_key('MY_SPREADSHEET_KEY')
        self.worksheet = sp.sheet1 # to overwrite worksheet class by worksheet in myDrive

Any other info

If you feel positve about these ideas, I would like to contribute as much as possible.

nithinmurali commented 2 years ago

Hi @rariyama , these suggestions sound very promising and can improve the developer experience.

  1. since we are using pytest, this can be easily achieved by creating a new command in Makefile for calling the pytest command to run specific functions pytest test_mod.py::test_func

  2. I usually test my local changes using manual_testing.py. But you are right, if someone has to run the online tests on their account, it would need some fiddling around in config files. It would be nice to have a simpler documented method to do that.