def test_update_rows_invalid_assign_hyperlink_url_and_sheet_id(self):
        self.client.as_test_scenario(
            'Update Rows - Invalid - Assign Hyperlink URL and SheetId')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({
            "columnId": 101,
            "value": "Google",
            "hyperlink": {
                "url": "http://google.com",
                "sheetId": 2
            }
        })
        first_row.cells.append({
            "columnId": 102,
            "value": "Bing",
            "hyperlink": {
                "url": "http://bing.com"
            }
        })

        with pytest.raises(ApiError) as e:
            self.client.Sheets.update_rows(1, [first_row])

        self.check_error_code(e, 1112)
    def test_update_rows_location_bottom(self):
        self.client.as_test_scenario('Update Rows - Location - Bottom')
        first_row = Row()
        first_row.id = 10
        first_row.to_bottom = True

        response = self.client.Sheets.update_rows(1, [first_row])

        assert response.result[0].row_number == 100
    def test_add_rows_location_bottom(self):
        self.client.as_test_scenario('Add Rows - Location - Bottom')

        first_row = Row()
        first_row.to_bottom = True
        first_row.cells.append({"columnId": 101, "value": "Apple"})
        first_row.cells.append({"columnId": 102, "value": "Red Fruit"})

        response = self.client.Sheets.add_rows(1, [first_row])

        assert response.result[0].row_number == 100
    def test_update_rows_clear_value_checkbox(self):
        self.client.as_test_scenario('Update Rows - Clear Value - Checkbox')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({"columnId": 101, "value": ""})

        response = self.client.Sheets.update_rows(1, [first_row])

        assert response.result[0].cells[0].column_id == 101
        assert response.result[0].cells[0].value is False
    def test_update_rows_clear_value_predecessor_list(self):
        self.client.as_test_scenario(
            'Update Rows - Clear Value - Predecessor List')

        row = Row()
        row.id = 10
        row.cells.append({'columnId': 123, 'value': ExplicitNull()})

        response = self.client.Sheets.update_rows(1, [row])

        assert response.result[0].cells[0].column_id == 123
        assert response.result[0].cells[0].value is None
    def test_update_rows_clear_value_cell_link(self):
        self.client.as_test_scenario('Update Rows - Clear Value - Cell Link')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({"columnId": 101, "value": ""})
        first_row.cells[0].link_in_from_cell = ExplicitNull()

        response = self.client.Sheets.update_rows(1, [first_row])

        assert response.result[0].cells[0].column_id == 101
        assert response.result[0].cells[0].value is None
        assert response.result[0].cells[0].link_in_from_cell is None
    def test_add_rows_assign_values_bool(self):
        self.client.as_test_scenario('Add Rows - Assign Values - Bool')

        first_row = Row()
        first_row.cells.append({"columnId": 101, "value": True})
        first_row.cells.append({"columnId": 102, "value": "This is True"})

        second_row = Row()
        second_row.cells.append({"columnId": 101, "value": False})
        second_row.cells.append({"columnId": 102, "value": "This is False"})

        response = self.client.Sheets.add_rows(1, [first_row, second_row])

        assert response.result[1].cells[0].value is False
    def test_add_rows_assign_values_int(self):
        self.client.as_test_scenario('Add Rows - Assign Values - Int')

        first_row = Row()
        first_row.cells.append({"columnId": 101, "value": 100})
        first_row.cells.append({"columnId": 102, "value": "One Hundred"})

        second_row = Row()
        second_row.cells.append({"columnId": 101, "value": 2.1})
        second_row.cells.append({"columnId": 102, "value": "Two Point One"})

        response = self.client.Sheets.add_rows(1, [first_row, second_row])

        assert response.result[1].cells[0].value == 2.1
    def test_add_rows_assign_values_string(self):
        self.client.as_test_scenario('Add Rows - Assign Values - String')

        first_row = Row()
        first_row.cells.append({"columnId": 101, "value": "Apple"})
        first_row.cells.append({"columnId": 102, "value": "Red Fruit"})

        second_row = Row()
        second_row.cells.append({"columnId": 101, "value": "Banana"})
        second_row.cells.append({"columnId": 102, "value": "Yellow Fruit"})

        response = self.client.Sheets.add_rows(1, [first_row, second_row])

        assert response.result[0].cells[0].value == "Apple"
Example #10
0
    def test_predecessor_serialization(self):
        pytest.skip('Skipping until mock API test is updated')
        self.client.as_test_scenario('Serialization - Predecessor')

        row = Row()
        row.cells.append({
            'columnId': 2,
            'objectValue': {
                'objectType': 'PREDECESSOR_LIST',
                'predecessors': [
                    {
                        'rowId': 3,
                        'type': 'FS',
                        'lag': {
                            'objectType': 'DURATION',
                            'negative': False,
                            'elapsed': False,
                            'weeks': 1.5,
                            'days': 2.5,
                            'hours': 3.5,
                            'minutes': 4.5,
                            'seconds': 5.5,
                            'milliseconds': 6
                        }
                    }
                ]
            }
        })

        response = self.client.Sheets.add_rows(1, row)

        assert response.result.cells[4].object_value.predecessors[0].lag.object_type == DURATION
    def test_update_rows_clear_value_hyperlink(self):
        self.client.as_test_scenario('Update Rows - Clear Value - Hyperlink')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({
            "columnId": 101,
            "value": "",
            "hyperlink": ExplicitNull()
        })

        response = self.client.Sheets.update_rows(1, [first_row])

        assert response.result[0].cells[0].column_id == 101
        assert response.result[0].cells[0].value is None
        assert response.result[0].cells[0].hyperlink is None
Example #12
0
    def test_cell_link_serialization(self):
        pytest.skip('Skipping until mock API test is updated')
        self.client.as_test_scenario('Serialization - Cell Link')

        updated_row = Row()
        updated_row.id = 2
        updated_row.cells.append({
            'columnId': 3,
            'value': ExplicitNull(),
            'linkInFromCell': {
                'sheetId': 4,
                'rowId': 5,
                'columnId': 6
            }
        })

        self.client.Sheets.update_rows(1, updated_row)
    def test_update_rows_assign_formulae(self):
        self.client.as_test_scenario('Update Rows - Assign Formulae')

        first_row = Row()
        first_row.id = 11
        first_row.cells.append({
            "columnId": 101,
            "formula": "=SUM([Column2]3, [Column2]4)*2"
        })
        first_row.cells.append({
            "columnId":
            102,
            "formula":
            "=SUM([Column2]3, [Column2]3, [Column2]4)"
        })

        response = self.client.Sheets.update_rows(1, [first_row])

        assert response.result[0].cells[0].value == 14
Example #14
0
    def test_rows_serialization(self):
        pytest.skip('Skipping until mock API test is updated')
        self.client.as_test_scenario('Serialization - Rows')

        row = Row()
        row.expanded = True
        row.format_ = ',,,,,,,,4,,,,,,,'
        row.locked = False
        row.cells.append({
            'columnId': 2,
            'value': 'url link',
            'strict': False,
            'hyperlink': {
                'url': 'https://google.com'
            }
        })
        row.cells.append({
            'columnId': 3,
            'value': 'sheet id link',
            'strict': False,
            'hyperlink': {
                'sheetId': 4
            }
        })
        row.cells.append({
            'columnId': 5,
            'value': 'report id link',
            'strict': False,
            'hyperlink': {
                'reportId': 6
            }
        })

        response = self.client.Sheets.add_rows(1, row)

        cells = response.result.cells

        assert cells[0].hyperlink.url == 'https://google.com'
        assert cells[1].hyperlink.sheet_id == 4
        assert cells[2].hyperlink.report_id == 6
    def test_update_rows_invalid_assign_value_and_formulae(self):
        self.client.as_test_scenario(
            'Update Rows - Invalid - Assign Value and Formulae')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({
            "columnId": 101,
            "formula": "=SUM([Column2]3, [Column2]4)*2",
            "value": "20"
        })
        first_row.cells.append({
            "columnId":
            102,
            "formula":
            "=SUM([Column2]3, [Column2]3, [Column2]4)"
        })

        with pytest.raises(ApiError) as e:
            self.client.Sheets.update_rows(1, [first_row])

        self.check_error_code(e, 1163)
    def test_update_rows_assign_values_hyperlink(self):
        self.client.as_test_scenario('Update Rows - Assign Values - Hyperlink')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({
            "columnId": 101,
            "value": "Google",
            "hyperlink": {
                "url": "http://google.com"
            }
        })
        first_row.cells.append({
            "columnId": 102,
            "value": "Bing",
            "hyperlink": {
                "url": "http://bing.com"
            }
        })

        response = self.client.Sheets.update_rows(1, [first_row])

        assert response.result[0].cells[0].hyperlink.url == "http://google.com"
    def test_update_rows_invalid_assign_hyperlink_and_cell_link(self):
        self.client.as_test_scenario(
            'Update Rows - Invalid - Assign Hyperlink and Cell Link')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({
            "columnId": 101,
            "value": "",
            "linkInFromCell": {
                "sheetId": 2,
                "rowId": 20,
                "columnId": 201
            },
            "hyperlink": {
                "url": "www.google.com"
            }
        })

        with pytest.raises(ApiError) as e:
            self.client.Sheets.update_rows(1, [first_row])

        self.check_error_code(e, 1109)
    def test_update_rows_assign_values_hyperlink_report_id(self):
        self.client.as_test_scenario(
            'Update Rows - Assign Values - Hyperlink ReportID')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({
            "columnId": 101,
            "value": "Report9",
            "hyperlink": {
                "reportId": 9
            }
        })
        first_row.cells.append({
            "columnId": 102,
            "value": "Report8",
            "hyperlink": {
                "reportId": 8
            }
        })

        response = self.client.Sheets.update_rows(1, [first_row])

        assert response.result[0].cells[1].hyperlink.report_id == 8
    def test_update_rows_assign_values_hyperlink_sheet_id(self):
        self.client.as_test_scenario(
            'Update Rows - Assign Values - Hyperlink SheetID')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({
            "columnId": 101,
            "value": "Sheet2",
            "hyperlink": {
                "sheetId": 2
            }
        })
        first_row.cells.append({
            "columnId": 102,
            "value": "Sheet3",
            "hyperlink": {
                "sheetId": 3
            }
        })

        response = self.client.Sheets.update_rows(1, [first_row])

        assert response.result[0].cells[1].hyperlink.sheet_id == 3
    def test_add_rows_assign_formulae(self):
        self.client.as_test_scenario('Add Rows - Assign Formulae')

        first_row = Row()
        first_row.cells.append({
            "columnId": 101,
            "formula": "=SUM([Column2]3, [Column2]4)*2"
        })
        first_row.cells.append({
            "columnId":
            102,
            "formula":
            "=SUM([Column2]3, [Column2]3, [Column2]4)"
        })

        response = self.client.Sheets.add_rows(1, [first_row])

        assert response.result[0].cells[
            1].formula == "=SUM([Column2]3, [Column2]3, [Column2]4)"
    def test_add_rows_assign_object_value_predecessor_list_using_float_duration(
            self):
        self.client.as_test_scenario(
            'Add Rows - Assign Object Value - Predecessor List (using floats)')

        lag = Duration({'objectType': 'DURATION', 'days': 2.5})

        predecessor_list = PredecessorList()
        predecessor_list.predecessors.append({
            'rowId': 10,
            'type': 'FS',
            'lag': lag
        })

        row = Row()
        row.cells.append({'columnId': 101, 'objectValue': predecessor_list})

        response = self.client.Sheets.add_rows(1, [row])

        assert response.result[0].cells[1].display_value == '2FS +2.5d'
    def test_update_rows_assign_values_bool(self):
        self.client.as_test_scenario('Update Rows - Assign Values - Bool')

        first_row = Row()
        first_row.id = 10
        first_row.cells.append({"columnId": 101, "value": True})
        first_row.cells.append({"columnId": 102, "value": "This is True"})

        second_row = Row()
        second_row.id = 11
        second_row.cells.append({"columnId": 101, "value": False})
        second_row.cells.append({"columnId": 102, "value": "This is False"})

        response = self.client.Sheets.update_rows(1, [first_row, second_row])

        assert response.result[1].cells[0].display_value == "false"
    def test_add_rows_assign_object_value_predecessor_list(self):
        self.client.as_test_scenario(
            'Add Rows - Assign Object Value - Predecessor List')

        lag = Duration({"objectType": "DURATION", "days": 2, "hours": 4})

        predecessor_list = PredecessorList()
        predecessor_list.predecessors.append({
            "rowId": 10,
            "type": "FS",
            "lag": lag
        })

        first_row = Row()
        first_row.cells.append({
            "columnId": 101,
            "objectValue": predecessor_list
        })

        response = self.client.Sheets.add_rows(1, [first_row])

        assert response.result[0].cells[1].display_value == "2FS +2d 4h"
Example #24
0
    def test_bulk_failure_serialization(self):
        self.client.as_test_scenario('Serialization - BulkFailure')

        row1 = Row()
        row1.to_bottom = True
        row1.cells.append({
            'columnId': 2,
            'value': 'Some Value'
        })

        row2 = Row()
        row2.to_bottom = True
        row2.cells.append({
            'columnId': 3,
            'value': 'Some Value'
        })

        response = self.client.Sheets.add_rows_with_partial_success(1, [row1, row2])

        assert response.result[0].cells[0].value == 'Some Value'
        assert response.failed_items[0].error.error_code == 1036