def test_deploy(self): """ Test _deploy helper function """ zdb = Zerodb('zdb', data=self.valid_data) zdb_sal = MagicMock(zt_identity='identity') zdb._node_sal.primitives.from_dict.return_value = zdb_sal zdb._deploy() assert zdb.data['ztIdentity'] == zdb_sal.zt_identity
def test_namespace_delete(self): """ Test namespace_delete action """ zdb = Zerodb('zdb', data=self.valid_data) zdb.state.set('status', 'running', 'ok') zdb._namespace_exists_update_delete = MagicMock(return_value=True) zdb._deploy = MagicMock() zdb.namespace_delete('namespace') zdb._zerodb_sal.deploy.assert_called_once_with()
def test_namespace_create_namespace_exists(self): """ Test namespace_set action """ with pytest.raises(ValueError, message='namespace_create action should raise an error if namespace exists'): zdb = Zerodb('zdb', data=self.valid_data) zdb.state.set('status', 'running', 'ok') zdb._deploy = MagicMock() zdb._namespace_exists_update_delete = MagicMock(return_value=True) zdb.namespace_create('namespace', 12, 'secret')
def test_namespace_create(self): """ Test namespace_set action """ zdb = Zerodb('zdb', data=self.valid_data) zdb.state.set('status', 'running', 'ok') zdb._deploy = MagicMock() zdb._namespace_exists_update_delete = MagicMock(return_value=False) zdb.namespace_create('namespace', 12, 'secret') zdb._zerodb_sal.deploy.assert_called_once_with() zdb._namespace_exists_update_delete.assert_called_once_with('namespace') assert zdb.data['namespaces'] == [{ 'name': 'namespace', 'size': 12, 'password': '******', 'public': True }]