Exemplo n.º 1
0
    def test_simple_create_many(self, mock):
        """Ensure that simple CREATE many method will add a new row to our
        existing a spreadsheet"""
        mock.return_value = MagicMock(status_code=200,
                                      content=json.dumps([{
                                          'id': '1',
                                          'name': 'Peter',
                                          'score': '42'
                                      }, {
                                          'id': '2',
                                          'name': 'Lois',
                                          'score': '89'
                                      }]))

        client = SheetsuClient(**self.kwargs)
        response = client.create_many(*[
            dict(id=1, name="Peter", score=42),
            dict(id=2, name="Louis", score=89)
        ])

        self.assertEqual(response, [{
            'id': '1',
            'name': 'Peter',
            'score': '42'
        }, {
            'id': '2',
            'name': 'Lois',
            'score': '89'
        }])
Exemplo n.º 2
0
    def test_create_one_or_many_fail(self, mock):
        """Ensure that if request fails, that proper response is given"""
        mock.return_value = MagicMock(status_code=400)

        client = SheetsuClient(**self.kwargs)
        response = client.create_one()
        self.assertIsNone(response)
        response = client.create_many()
        self.assertIsNone(response)