Esempio n. 1
0
 def test_namespace_exist_update_delete_invalid_property(self):
     """
     Test _namespace_exists_update_delete raises ValueError if you supply invalid prop
     """
     with pytest.raises(ValueError,
                        message='_namespace_exist_update_dekete action should raise an error if user uses invalid prop'):
         zdb = Zerodb('zdb', data=self.valid_data)
         zdb._namespace_exists_update_delete('namespace', prop='prop')
Esempio n. 2
0
 def test_namespace_exist_update_delete_runtimeerror(self):
     """
     Test _namespace_exists_update_delete raises RunTimeError if you try to update and delete a namespace at the same time
     """
     with pytest.raises(ValueError,
                        message='_namespace_exist_update_delete action should raise an error if user is trying to set property and delete namespace'):
         zdb = Zerodb('zdb', data=self.valid_data)
         zdb._namespace_exists_update_delete('namespace', prop='password', delete=True)
Esempio n. 3
0
 def test_namespace_exist_update_delete_exists(self):
     """
     Test _namespace_exists_update_delete if namespace exists
     """
     self.valid_data['namespaces'].append({'name': 'namespace', 'size': 20, 'public': True, 'password': ''})
     zdb = Zerodb('zdb', data=self.valid_data)
     assert zdb._namespace_exists_update_delete('namespace') is True
Esempio n. 4
0
 def test_namespace_exist_update_delete_update_prop(self):
     """
     Test _namespace_exists_update_delete if namespace exists and prop is updated
     """
     self.valid_data['namespaces'].append({'name': 'namespace', 'size': 20, 'public': True, 'password': ''})
     zdb = Zerodb('zdb', data=self.valid_data)
     assert zdb._namespace_exists_update_delete('namespace', prop='size', value=30) is True
     assert zdb.data['namespaces'] == [{'name': 'namespace', 'size': 30, 'public': True, 'password': ''}]
Esempio n. 5
0
 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()
Esempio n. 6
0
 def test_namespace_set_namespace_doesnt_exist(self):
     """
     Test namespace_set action if namespace doesn't exist
     """
     with pytest.raises(LookupError,
                        message='namespace_set action should raise an error if namespace doesn\'t exists'):
         zdb = Zerodb('zdb', data=self.valid_data)
         zdb.state.set('status', 'running', 'ok')
         zdb._namespace_exists_update_delete = MagicMock(return_value=False)
         zdb.namespace_set('namespace', 'size', 12)
Esempio n. 7
0
 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')
Esempio n. 8
0
    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
        }]
Esempio n. 9
0
 def test_namespace_exist_update_delete_doesnt_exist(self):
     """
     Test _namespace_exists_update_delete if namespace doesn't exist
     """
     zdb = Zerodb('zdb', data=self.valid_data)
     assert zdb._namespace_exists_update_delete('namespace') is False