Example #1
0
    def test_get_abstract_success(self):
        vending_machine = VendingMachine()

        with patch('requests.models.Response.json',
                   MagicMock(return_value={'AbstractText': ''})):
            self.assertEqual('', vending_machine._get_abstract('test'))

        with patch('requests.models.Response.json',
                   MagicMock(return_value={'AbstractText': 'Test text'})):
            self.assertEqual('Test text',
                             vending_machine._get_abstract('test'))
Example #2
0
    def test_get_abstract_request_exception(self):
        vending_machine = VendingMachine()

        with patch(
                'requests.get',
                MagicMock(side_effect=requests.exceptions.RequestException)):
            self.assertEqual('', vending_machine._get_abstract('test'))