Esempio n. 1
0
    def test_set(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        handler.set('a domain', 'a name', 'a value')

        mock_dss_client.return_value.set.assert_called_once_with(
            'a domain', 'a name', 'a value')
Esempio n. 2
0
    def test_get_domains_exception(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        mock_dss_client.return_value.get_domains.side_effect = dss_error.Error(
            'no domains')

        with self.assertRaises(CMError) as context:
            handler.get_domains()
Esempio n. 3
0
    def test_get_domains(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

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

        domains = handler.get_domains()

        assert domains == expected_result
Esempio n. 4
0
    def test_delete_domain_non_existent(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'
        ]

        handler.delete_domain('not domain')

        mock_dss_client.return_value.get_domains.assert_called_once()
        mock_dss_client.return_value.delete_domain.assert_not_called()
Esempio n. 5
0
    def test_set_dss_fails(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        mock_dss_client.return_value.set.side_effect = dss_error.Error(
            'some error')

        with self.assertRaises(CMError) as context:
            handler.set('a domain', 'a name', 'a value')

        mock_dss_client.return_value.set.assert_called_once_with(
            'a domain', 'a name', 'a value')
Esempio n. 6
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()
Esempio n. 7
0
    def test_get(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.return_value = OrderedDict([
            ('name', 'value')
        ])

        value = handler.get('a domain', 'name')

        assert value == 'value'
Esempio n. 8
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
Esempio n. 9
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')
Esempio n. 10
0
    def test_get_non_existing_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'
        ]
        mock_dss_client.return_value.get_domain.return_value = OrderedDict([
            ('name', 'value')
        ])

        value = handler.get('some domain', 'a name')

        assert value is None

        mock_dss_client.return_value.get_domain.assert_not_called()
        mock_dss_client.return_value.get_domains.assert_called_once()
Esempio n. 11
0
    def test_delete_non_existing_name(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.return_value = OrderedDict([
            ('name', 'value')
        ])

        handler.delete('a domain', 'a name')

        mock_dss_client.return_value.get_domain.assert_called_once_with(
            'a domain')
        mock_dss_client.return_value.delete.assert_not_called()
Esempio n. 12
0
    def test_delete_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.return_value = OrderedDict([
            ('name', 'value')
        ])

        mock_dss_client.return_value.delete.side_effect = dss_error.Error(
            'some error')

        with self.assertRaises(CMError) as context:
            handler.delete('a domain', 'name')

        mock_dss_client.return_value.delete.assert_called_once_with(
            'a domain', 'name')
Esempio n. 13
0
    def test_init(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        mock_dss_client.assert_called_once_with('test_uri')