Пример #1
0
 def test_namespace_info_before_start(self):
     """
     Test namespace_info action without start
     """
     with pytest.raises(StateCheckError,
                        message='namespace action should raise an error if zerodb is not started'):
         zdb = Zerodb('zdb', data=self.valid_data)
         zdb.namespace_info('namespace')
Пример #2
0
 def test_namespace_info_doesnt_exist(self):
     """
     Test namespace_info action without start
     """
     with pytest.raises(LookupError,
                        message='namespace action should raise an error if namespace doesnt exist'):
         zdb = Zerodb('zdb', data=self.valid_data)
         zdb.state.set('status', 'running', 'ok')
         zdb.namespace_info('namespace')
Пример #3
0
    def test_namespace_info(self):
        """
        Test namespace_info action
        """
        zdb = Zerodb('zdb', data=self.valid_data)
        zdb.state.set('actions', 'start', 'ok')
        zdb.api.services.get = MagicMock()
        zdb.namespace_info('namespace')

        zdb._zerodb_sal.get_namespace_info.assert_called_once_with('namespace')
Пример #4
0
    def test_namespace_info(self):
        """
        Test namespace_info action
        """
        self.valid_data['namespaces'].append({'name': 'namespace', 'size': 20, 'public': True, 'password': ''})

        zdb = Zerodb('zdb', data=self.valid_data)
        info_dict = {
            'data_limits_bytes': 21474836480,
            'data_size_bytes': 0,
            'data_size_mb': 0.0,
            'entries': 0,
            'index_size_bytes': 0,
            'index_size_kb': 0.0,
            'name': 'two',
            'password': '******',
            'public': 'yes'
        }
        zdb.state.set('status', 'running', 'ok')
        namespace = MagicMock()
        namespace.info.return_value.to_dict.return_value = info_dict
        zdb_sal = MagicMock(namespaces={'namespace': namespace})
        zdb._node_sal.primitives.from_dict.return_value = zdb_sal

        assert zdb.namespace_info('namespace') == info_dict