|
| 1 | +""" |
| 2 | +Copyright 2022 Google LLC |
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +you may not use this file except in compliance with the License. |
| 5 | +You may obtain a copy of the License at |
| 6 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +Unless required by applicable law or agreed to in writing, software |
| 8 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +See the License for the specific language governing permissions and |
| 11 | +limitations under the License. |
| 12 | +""" |
| 13 | + |
| 14 | +import unittest |
| 15 | +from pprint import pformat |
| 16 | + |
| 17 | +import slides_image_merging |
| 18 | +from base_test import BaseTest |
| 19 | + |
| 20 | + |
| 21 | +class TestTextMerging(BaseTest): |
| 22 | + """Unit test for text merging snippet""" |
| 23 | + TEMPLATE_PRESENTATION_ID = '10QnVUx1X2qHsL17WUidGpPh_SQhXYx40CgIxaKk8jU4' |
| 24 | + DATA_SPREADSHEET_ID = '17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM' |
| 25 | + IMAGE_URL = 'https://picsum.photos/200' |
| 26 | + CHART_ID = 1107320627 |
| 27 | + CUSTOMER_NAME = 'Fake Customer' |
| 28 | + |
| 29 | + def test_image_merging(self): |
| 30 | + """image merging function """ |
| 31 | + response = slides_image_merging.image_merging( |
| 32 | + self.TEMPLATE_PRESENTATION_ID, |
| 33 | + self.IMAGE_URL, |
| 34 | + self.CUSTOMER_NAME) |
| 35 | + presentation_id = response.get('presentationId') |
| 36 | + self.delete_file_on_cleanup(presentation_id) |
| 37 | + self.assertIsNotNone(presentation_id, msg=pformat(response)) |
| 38 | + self.assertEqual(2, len(response.get('replies')), |
| 39 | + msg=pformat(response)) |
| 40 | + num_replacements = 0 |
| 41 | + for reply in response.get('replies'): |
| 42 | + if isinstance(reply, int): |
| 43 | + num_replacements += reply.get('replaceAllShapesWithImage') \ |
| 44 | + .get('occurrencesChanged') |
| 45 | + |
| 46 | + |
| 47 | +if __name__ == "__main__": |
| 48 | + unittest.main() |
0 commit comments