Ejemplo n.º 1
0
    def test_search_for_organization_fails(self, mock_get):
        mock_get.return_value = Mock(json=Mock(return_value={}))

        cb = CrunchBase('123')
        data = cb.organizations('organization')

        mock_get.assert_called_with(
            'https://api.crunchbase.com/v3.1/organizations?'
            'name=organization&user_key=123')
        self.assertIsNone(data)
Ejemplo n.º 2
0
    def test_search_for_organization_fails(self, mock_get):
        mock_get.return_value = Mock(json=Mock(return_value={}))

        cb = CrunchBase('123')
        data = cb.organizations('organization')

        mock_get.assert_called_with(
            'https://api.crunchbase.com/v/3/organizations?'
            'name=organization&user_key=123')
        self.assertIsNone(data)
Ejemplo n.º 3
0
    def test_search_for_organization_returns_a_list_of_matches(self, mock_get):
        mock_json = make_mock_response_json({
            "metadata": {
                "image_path_prefix": "https://example.com/",
                "www_path_prefix": "https://www.crunchbase.com/",
                "api_path_prefix": "https://api.crunchbase.com/v/3/",
                "version": 2
                },
            "data": {
                "paging": {
                    "items_per_page": 1000,
                    "current_page": 1,
                    "number_of_pages": 1,
                    "next_page_url": None,
                    "prev_page_url": None,
                    "total_items": 6,
                    "sort_order": "custom"
                    },
                "items": [
                    {
                        "uuid": "uuid1",
                        "type": "Organization",
                        "properties": {
                            "updated_at": 1415895087,
                            "created_at": 1371717055,
                            "path": "organization/organization",
                            "name": "organization",
                        }
                    },
                    {
                        "uuid": "uuid2",
                        "type": "Organization",
                        "properties": {
                            "updated_at": 1415768560,
                            "created_at": 1310530681,
                            "path": "organization/organization2",
                            "name": "organization2",
                        }
                    }
                ]
            }
        })
        mock_get.return_value = mock_json

        cb = CrunchBase('123')
        orgs = cb.organizations('organization')
        mock_get.assert_called_with(
            'https://api.crunchbase.com/v/3/organizations?'
            'name=organization&user_key=123')

        self.assertIsInstance(orgs, Page)
Ejemplo n.º 4
0
 def test_exception_raised_when_making_calls(self):
     with patch('pycrunchbase.pycrunchbase.requests') as mock_request:
         mock_request.get = Mock(side_effect=HTTPError())
         cb = CrunchBase('123')
         with self.assertRaises(HTTPError):
             cb.organizations('organization')
Ejemplo n.º 5
0
 def test_exception_raised_when_making_calls(self):
     with patch('pycrunchbase.pycrunchbase.requests') as mock_request:
         mock_request.get = Mock(side_effect=HTTPError())
         cb = CrunchBase('123')
         with self.assertRaises(HTTPError):
             cb.organizations('organization')