Beispiel #1
0
    def test_get_domain_not_existing(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        mock_dss_client.return_value.get_domains.return_value = [
            'a domain', 'b domain', 'c domain'
        ]

        domain = handler.get_domain('not domain')

        assert domain is None

        mock_dss_client.return_value.get_domains.assert_called_once()
        mock_dss_client.return_value.get_domain.assert_not_called()
Beispiel #2
0
    def test_get_domain(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        mock_dss_client.return_value.get_domains.return_value = [
            'a domain', 'b domain', 'c domain'
        ]

        expected_result = OrderedDict([('name1', 'value1'),
                                       ('name2', 'value2')])
        mock_dss_client.return_value.get_domain.return_value = expected_result

        domain = handler.get_domain('a domain')

        assert domain == expected_result
Beispiel #3
0
    def test_get_domain_dss_fails(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        mock_dss_client.return_value.get_domains.return_value = [
            'a domain', 'b domain', 'c domain'
        ]
        mock_dss_client.return_value.get_domain.side_effect = dss_error.Error(
            'some error')

        with self.assertRaises(CMError) as context:
            domain = handler.get_domain('a domain')

        mock_dss_client.return_value.get_domains.assert_called_once()
        mock_dss_client.return_value.get_domain.assert_called_once_with(
            'a domain')