Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions sheets/snippets/test_sheets_append_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest

import sheets_append_values
from base_test import BaseTest


class Testappendvalues(BaseTest):
"""Unit test for append value Sheet snippet"""

def test_append_values(self):
"""test append values function"""
spreadsheet_id = self.create_test_spreadsheet()
self.populate_values(spreadsheet_id)
result = sheets_append_values.append_values(spreadsheet_id,
'Sheet1', 'USER_ENTERED', [
['A', 'B'],
['C', 'D']
])
self.assertIsNotNone(result)
self.assertEqual('Sheet1!A1:J10', result.get('tableRange'))
updates = result.get('updates')
self.assertEqual('Sheet1!A11:B12', updates.get('updatedRange'))
self.assertEqual(2, updates.get('updatedRows'))
self.assertEqual(2, updates.get('updatedColumns'))
self.assertEqual(4, updates.get('updatedCells'))


if __name__ == "__main__":
unittest.main()
38 changes: 38 additions & 0 deletions sheets/snippets/test_sheets_batch_get_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest

import sheets_batch_get_values
from base_test import BaseTest


class Testgetvalues(BaseTest):
"""Unit test class for get value Sheet snippet"""

def test_batch_get_values(self):
"""test batch get values function"""
spreadsheet_id = self.create_test_spreadsheet()
self.populate_values(spreadsheet_id)
result = sheets_batch_get_values.batch_get_values(spreadsheet_id,
['A1:A3', 'B1:C1'])
self.assertIsNotNone(result)
valueranges = result.get('valueRanges')
self.assertIsNotNone(valueranges)
self.assertEqual(2, len(valueranges))
values = valueranges[0].get('values')
self.assertEqual(3, len(values))


if __name__ == "__main__":
unittest.main()
41 changes: 41 additions & 0 deletions sheets/snippets/test_sheets_batch_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest

import sheets_batch_update
import sheets_create
from base_test import BaseTest


class Testbatchupdate(BaseTest):
"""Unit test class for Batch update Sheet snippet"""

def test_batch_update(self):
"""test_batch_update function """
spreadsheet_id = sheets_create.create('Title')
self.populate_values(spreadsheet_id)
response = sheets_batch_update.\
sheets_batch_update(spreadsheet_id, 'New Title',
'Hello', 'Goodbye')
self.assertIsNotNone(response)
replies = response.get('replies')
self.assertIsNotNone(replies)
self.assertEqual(2, len(replies))
find_replace_response = replies[1].get('findReplace')
self.assertIsNotNone(find_replace_response)
self.assertEqual(100, find_replace_response.get('occurrencesChanged'))


if __name__ == "__main__":
unittest.main()
40 changes: 40 additions & 0 deletions sheets/snippets/test_sheets_batch_update_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest

import sheets_batch_update_values
from base_test import BaseTest


class Testbatchupdatevalues(BaseTest):
"""Unit test for Batch update value Sheet snippet"""

def test_batch_update_values(self):
"""batch updates values"""
spreadsheet_id = self.create_test_spreadsheet()
result = sheets_batch_update_values. \
batch_update_values(spreadsheet_id,
'A1:B2', 'USER_ENTERED', [
['A', 'B'],
['C', 'D']
])
self.assertIsNotNone(result)
self.assertEqual(1, len(result.get('responses')))
self.assertEqual(2, result.get('totalUpdatedRows'))
self.assertEqual(2, result.get('totalUpdatedColumns'))
self.assertEqual(4, result.get('totalUpdatedCells'))


if __name__ == "__main__":
unittest.main()
33 changes: 33 additions & 0 deletions sheets/snippets/test_sheets_conditional_formatting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest

import sheets_conditional_formatting
from base_test import BaseTest


class Testconditionalformatting(BaseTest):
"""Unit test for sheets conditional_formatting value Sheet snippet"""

def test_conditional_formatting(self):
"""sheets_conditional_formatting function"""
spreadsheet_id = self.create_test_spreadsheet()
self.populate_values(spreadsheet_id)
response = sheets_conditional_formatting.\
conditional_formatting(spreadsheet_id)
self.assertEqual(2, len(response.get('replies')))


if __name__ == "__main__":
unittest.main()
30 changes: 30 additions & 0 deletions sheets/snippets/test_sheets_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest

import sheets_create
from base_test import BaseTest


class Testsheetscreate(BaseTest):
"""Unit test class for Create Sheet snippet"""
def test_create(self):
"""sheet function for Create sheet """
spreadsheet_id = sheets_create.create('Title')
self.assertIsNotNone(spreadsheet_id)
self.delete_file_on_cleanup(spreadsheet_id)


if __name__ == "__main__":
unittest.main()
30 changes: 30 additions & 0 deletions sheets/snippets/test_sheets_filter_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest
import sheets_filter_views
from base_test import BaseTest


class Testfilterviews(BaseTest):
"""Unit test for sheets conditional_formatting value Sheet snippet"""

def test_filter_views(self):
"""test filter view function"""
spreadsheet_id = self.create_test_spreadsheet()
self.populate_values(spreadsheet_id)
sheets_filter_views.filter_views(spreadsheet_id)


if __name__ == "__main__":
unittest.main()
36 changes: 36 additions & 0 deletions sheets/snippets/test_sheets_get_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest

import sheets_get_values
from base_test import BaseTest


class Testgetvalues(BaseTest):
"""Unit test class for get value Sheet snippet"""

def test_get_values(self):
"""test_get_values"""
spreadsheet_id = self.create_test_spreadsheet()
self.populate_values(spreadsheet_id)
result = sheets_get_values.get_values(spreadsheet_id, 'A1:C2')
self.assertIsNotNone(result)
values = result.get('values')
self.assertIsNotNone(values)
self.assertEqual(2, len(values))
self.assertEqual(3, len(values[0]))


if __name__ == "__main__":
unittest.main()
32 changes: 32 additions & 0 deletions sheets/snippets/test_sheets_pivot_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest

import sheets_pivot_tables
from base_test import BaseTest


class Testpivottables(BaseTest):
"""Unit test for Pivot tables value Sheet snippet"""

def test_pivot_tables(self):
"""pivot table function"""
spreadsheet_id = self.create_test_spreadsheet()
self.populate_values(spreadsheet_id)
response = sheets_pivot_tables.pivot_tables(spreadsheet_id)
self.assertIsNotNone(response)


if __name__ == "__main__":
unittest.main()
38 changes: 38 additions & 0 deletions sheets/snippets/test_sheets_update_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import unittest

import sheets_update_values
from base_test import BaseTest


class Testupdatesvalues(BaseTest):
"""Unit test for update value Sheet snippet"""

def test_update_values(self):
"""test updates_values"""
spreadsheet_id = self.create_test_spreadsheet()
result = sheets_update_values.update_values(spreadsheet_id,
'A1:B2', 'USER_ENTERED', [
['A', 'B'],
['C', 'D']
])
self.assertIsNotNone(result)
self.assertEqual(2, result.get('updatedRows'))
self.assertEqual(2, result.get('updatedColumns'))
self.assertEqual(4, result.get('updatedCells'))


if __name__ == "__main__":
unittest.main()