Example #1
0
    def test_getJson(self):
        from pyEX.common import _getJson, PyEXception
        with patch('requests.get') as mock:
            mock.return_value = MagicMock()
            mock.return_value.status_code = 200
            _getJson('')

            mock.return_value.status_code = 404
            try:
                _getJson('')
                assert False
            except PyEXception:
                pass
Example #2
0
    def test_getJson2(self):
        from pyEX.common import PyEXception, _getJson

        with patch("requests.get") as mock, patch("pickle.dump"):
            mock.return_value = MagicMock()
            mock.return_value.status_code = 200
            _getJson("", "test", "test")

            mock.return_value.status_code = 404
            try:
                _getJson("", "test", "test")
                assert False
            except PyEXception:
                pass
Example #3
0
 def test_getJson(self):
     from pyEX.common import _getJson
     with patch('requests.get') as mock:
         mock.return_value = MagicMock()
         mock.return_value.status_code = 200
         _getJson('')