def test_from_dict_throws_key_error_when_missing_attr(self):
     data_keys = mock_config.backup_configuration().keys()
     for key in data_keys:
         mock = mock_config.backup_configuration()
         del mock[key]
         with self.assertRaises(KeyError):
             backup_config.from_dict(mock)
Exemplo n.º 2
0
 def test_from_dict_throws_key_error_when_missing_attr(self):
     data_keys = mock_config.backup_configuration().keys()
     for key in data_keys:
         mock = mock_config.backup_configuration()
         del mock[key]
         with self.assertRaises(KeyError):
             backup_config.from_dict(mock)
 def test_reload_works(self):
     url = '{0}/backup-configuration/{1}'.format(self.connection.host,
                                                 self.config.id)
     conf = mock_config.backup_configuration(agent_id=100)
     HTTPretty.register_uri(HTTPretty.GET, url, status=200,
                            body=json.dumps(conf))
     self.config.reload()
     self.assertEqual(self.config.agent_id, 100)
Exemplo n.º 4
0
 def test_fetch_backup_configurations_works(self):
     url = '{0}/backup-configuration/system/{1}'.format(
         self.conn.host, self.agent.id)
     data = json.dumps(
         [mock_config.backup_configuration() for i in range(10)])
     HTTPretty.register_uri(HTTPretty.GET, url, status=200, body=data)
     confs = list(self.agent.backup_configurations)
     self.assertEqual(len(confs), 10)
     for conf in confs:
         self.assertEqual(conf.name, 'mock')
Exemplo n.º 5
0
 def test_reload_works(self):
     url = '{0}/backup-configuration/{1}'.format(self.connection.host,
                                                 self.config.id)
     conf = mock_config.backup_configuration(agent_id=100)
     HTTPretty.register_uri(HTTPretty.GET,
                            url,
                            status=200,
                            body=json.dumps(conf))
     self.config.reload()
     self.assertEqual(self.config.agent_id, 100)
 def test_fetch_backup_configurations_works(self):
     url = '{0}/backup-configuration/system/{1}'.format(self.conn.host,
                                                        self.agent.id)
     data = json.dumps([mock_config.backup_configuration()
                        for i in range(10)])
     HTTPretty.register_uri(HTTPretty.GET, url, status=200, body=data)
     confs = list(self.agent.backup_configurations)
     self.assertEqual(len(confs), 10)
     for conf in confs:
         self.assertEqual(conf.name, 'mock')
Exemplo n.º 7
0
 def setUp(self):
     self.connection = TestBackupConfiguration.connection
     self.client = Client(self.connection)
     self.email = TestBackupConfiguration.email
     self.agent = TestBackupConfiguration.agent
     config = mock_config.backup_configuration(name='integration',
                                               email=self.email,
                                               agent_id=self.agent.id)
     self.backup_config = backup_config.from_dict(config, self.connection)
     self.backup_config.include(['a'])
     self.backup_config.create()
Exemplo n.º 8
0
 def test_delete_works(self):
     config = mock_config.backup_configuration(name='deleter',
                                               email=self.email,
                                               agent_id=self.agent.id)
     conf = backup_config.from_dict(config, self.connection)
     conf.include(['a'])
     conf.create()
     conf.delete()
     with self.assertRaises(requests.exceptions.HTTPError):
         conf.reload()
     self.assertEqual(conf.deleted, True)
Exemplo n.º 9
0
 def test_from_dict_works_as_expected(self):
     body = mock_config.backup_configuration()
     config = backup_config.from_dict(body)
     self.assertEqual(config.id, 0)
     self.assertEqual(config.agent_id, 1)
     self.assertEqual(config.notify_on_failure, True)
     self.assertEqual(config.notify_on_success, False)
     self.assertEqual(config.email, '*****@*****.**')
     self.assertEqual(config.name, 'mock')
     self.assertEqual(config.encrypted, False)
     self.assertEqual(config.enabled, True)
     self.assertEqual(config.deleted, False)
 def setUp(self):
     self.connection = TestBackupConfiguration.connection
     self.client = Client(self.connection)
     self.email = TestBackupConfiguration.email
     self.agent = TestBackupConfiguration.agent
     config = mock_config.backup_configuration(
         name='integration', email=self.email,
         agent_id=self.agent.id
     )
     self.backup_config = backup_config.from_dict(config, self.connection)
     self.backup_config.include(['a'])
     self.backup_config.create()
 def test_delete_works(self):
     config = mock_config.backup_configuration(
         name='deleter', email=self.email,
         agent_id=self.agent.id
     )
     conf = backup_config.from_dict(config, self.connection)
     conf.include(['a'])
     conf.create()
     conf.delete()
     with self.assertRaises(requests.exceptions.HTTPError):
         conf.reload()
     self.assertEqual(conf.deleted, True)
 def test_from_dict_works_as_expected(self):
     body = mock_config.backup_configuration()
     config = backup_config.from_dict(body)
     self.assertEqual(config.id, 0)
     self.assertEqual(config.agent_id, 1)
     self.assertEqual(config.notify_on_failure, True)
     self.assertEqual(config.notify_on_success, False)
     self.assertEqual(config.email,
                      '*****@*****.**')
     self.assertEqual(config.name, 'mock')
     self.assertEqual(config.encrypted, False)
     self.assertEqual(config.enabled, True)
     self.assertEqual(config.deleted, False)
Exemplo n.º 13
0
 def setUp(self):
     _mock_auth(200)
     self.connection = Connection(username='******', region='dfw', password='******')
     config_api = mock_config.backup_configuration()
     self.config = backup_config.from_dict(config_api, self.connection)
def _quick_config(connection=None):
    return backup_config.from_dict(mock_config.backup_configuration(),
                                   connection=connection)
Exemplo n.º 15
0
def _quick_config(connection=None):
    return backup_config.from_dict(mock_config.backup_configuration(),
                                   connection=connection)
Exemplo n.º 16
0
def _mock_config(status, endpoint, config_id):
    reply = mock_config.backup_configuration(config_id)
    url = '{0}/{1}/{2}'.format(endpoint, 'backup-configuration', config_id)
    HTTPretty.register_uri(HTTPretty.GET, url, json.dumps(reply))
def _mock_config(status, endpoint, config_id):
    reply = mock_config.backup_configuration(config_id)
    url = '{0}/{1}/{2}'.format(endpoint, 'backup-configuration', config_id)
    HTTPretty.register_uri(HTTPretty.GET, url, json.dumps(reply))
 def setUp(self):
     _mock_auth(200)
     self.connection = Connection(username='******', region='dfw', password='******')
     config_api = mock_config.backup_configuration()
     self.config = backup_config.from_dict(config_api, self.connection)