Here are the examples of the python api tests.mock.response taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
7 Examples
3
Example 1
@patch('requests.get', return_value=response('account.json'))
def test_load(self, mock):
account = self.fa.account()
self.assertEquals('https://app.fakturoid.cz/api/v2/accounts/myslug/account.json', mock.call_args[0][0])
self.assertEquals("Alexandr Hejsek", account.name)
self.assertEquals("[email protected]", account.email)
3
Example 2
@patch('requests.get', return_value=response('subject_28.json'))
def test_load(self, mock):
subject = self.fa.subject(28)
self.assertEquals('https://app.fakturoid.cz/api/v2/accounts/myslug/subjects/28.json', mock.call_args[0][0])
self.assertEquals(28, subject.id)
self.assertEquals('47123737', subject.registration_no)
self.assertEquals('2012-06-02T09:34:47+02:00', subject.updated_at.isoformat())
3
Example 3
@patch('requests.get', return_value=response('subjects.json'))
def test_find(self, mock):
subjects = self.fa.subjects()
self.assertEquals('https://app.fakturoid.cz/api/v2/accounts/myslug/subjects.json', mock.call_args[0][0])
self.assertEquals(2, len(subjects))
self.assertEquals('Apple Czech s.r.o.', subjects[0].name)
3
Example 4
@patch('requests.get', return_value=response('invoice_9.json'))
def test_load(self, mock):
invoice = self.fa.invoice(9)
self.assertEquals('https://app.fakturoid.cz/api/v2/accounts/myslug/invoices/9.json', mock.call_args[0][0])
self.assertEquals('2012-0004', invoice.number)
3
Example 5
@patch('requests.get', return_value=response('generator_4.json'))
def test_load(self, mock):
g = self.fa.generator(4)
self.assertEquals('https://app.fakturoid.cz/api/v2/accounts/myslug/generators/4.json', mock.call_args[0][0])
self.assertEquals('Podpora', g.name)
3
Example 6
@patch('requests.get', return_value=response('generators.json'))
def test_find(self, mock):
generators = self.fa.generators()
self.assertEquals('https://app.fakturoid.cz/api/v2/accounts/myslug/generators.json', mock.call_args[0][0])
self.assertEquals(2, len(generators))
0
Example 7
@patch('requests.get', return_value=response('invoices.json'))
def test_find(self, mock):
invoice = self.fa.invoices()[:10]
self.assertEquals('https://app.fakturoid.cz/api/v2/accounts/myslug/invoices.json', mock.call_args[0][0])