Esempio n. 1
0
    def test_no_org_depts(self):
        """The function should not error out if the departments field doesn't appear in any orgs."""
        org_data = [{
            "id": 1234,
            "name": "Some Organization",
            "certTypes": []
        }, {
            "id": 4321,
            "name": "Another Organization",
            "certTypes": []
        }, {
            "id":
            9999,
            "name":
            "Some Organization",
            "certTypes": [],
            "departments": [
                {
                    "id": 8888,
                    "name": "Org Unit 1",
                    "certTypes": ["CodeSign", "SMIME", "SSL"]
                },
            ]
        }]
        # Setup the mocked response
        responses.add(responses.GET, self.api_url, json=org_data, status=200)

        org = Organization(client=self.client)
        data = org.find(dept_name="abc123")

        # Verify all the query information
        # There should only be one call the first time "all" is called in the constructor.
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, self.api_url)
        self.assertEqual(data, [])
Esempio n. 2
0
    def test_no_params(self):
        """The function should return the entire list of orgs if no parameters are passed."""
        # Setup the mocked response
        responses.add(responses.GET,
                      self.api_url,
                      json=self.valid_response,
                      status=200)

        org = Organization(client=self.client)
        data = org.find()

        # Verify all the query information
        # There should only be one call the first time "all" is called in the constructor.
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, self.api_url)
        self.assertEqual(data, self.valid_response)
Esempio n. 3
0
    def test_org_and_dept(self):
        """The function should return department data for department under a specific org."""
        # Setup the mocked response
        responses.add(responses.GET,
                      self.api_url,
                      json=self.valid_response,
                      status=200)

        org = Organization(client=self.client)
        data = org.find(org_name="Some Organization", dept_name="Org Unit 1")

        # Verify all the query information
        # There should only be one call the first time "all" is called in the constructor.
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, self.api_url)
        self.assertEqual(data[0], self.valid_response[0]["departments"][0])
Esempio n. 4
0
    def test_ne_dept(self):
        """The function should return an empty list if the department name doesn't exist."""
        # Setup the mocked response
        responses.add(responses.GET,
                      self.api_url,
                      json=self.valid_response,
                      status=200)

        org = Organization(client=self.client)
        data = org.find(dept_name="Nonexistent Department")

        # Verify all the query information
        # There should only be one call the first time "all" is called in the constructor.
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, self.api_url)
        self.assertEqual(data, [])
Esempio n. 5
0
    def test_org(self):
        """The function should return all the data about the specified organization name."""
        # Setup the mocked response
        responses.add(responses.GET,
                      self.api_url,
                      json=self.valid_response,
                      status=200)

        org = Organization(client=self.client)
        data = org.find(org_name="Some Organization")

        # Verify all the query information
        # There should only be one call the first time "all" is called in the constructor.
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, self.api_url)
        self.assertEqual(data, self.valid_response)