def test_get_all_record(self, pyg_auth):
        """return [{'col_name','val'}...]"""
        actor = pygsheetInteractor()
        actor.open_by_url("test_sheet")

        mock_matrix = [["c1", "c2"], ["a2", "a3"], ["b4", "b3"]]
        ans = [{"c1": "a2", "c2": "a3"}, {"c1": "b4", "c2": "b3"}]

        pyg_wks = pyg_auth().open_by_url().worksheet_by_title()
        pyg_wks.get_values.return_value = mock_matrix.copy()
        pyg_wks.cols, pyg_wks.rows = 2, 2
        ret = actor.get_all_record("not-important")
        assert ret == ans
Пример #2
0
    def test_get_all_record(self, pyg_auth):
        '''return [{'col_name','val'}...]
        '''
        actor = pygsheetInteractor()
        actor.open_by_url('test_sheet')

        mock_matrix = [['c1', 'c2'], ['a2', 'a3'], ['b4', 'b3']]
        ans = [{'c1': 'a2', 'c2': 'a3'}, {'c1': 'b4', 'c2': 'b3'}]

        pyg_wks = pyg_auth().open_by_url().worksheet_by_title()
        pyg_wks.get_values.return_value = mock_matrix.copy()
        pyg_wks.cols, pyg_wks.rows = 2, 2
        ret = actor.get_all_record('test_wks_title')
        assert (ret == ans)
Пример #3
0
 def test_interactor_auth_on_create(self, pyg_auth):
     actor = pygsheetInteractor()
     pyg_auth.assert_called_once()
Пример #4
0
 def test_interactor_need_to_call_open_url_before_use(self):
     actor = pygsheetInteractor(pygsheets)
     with pytest.raises(RuntimeError):
         actor.get_all_record('not-important')