def test_process_set_printsIfNoServer(self, mock_from, mock_getby, mock_print): self.fs.create_file(get_config_location()) args = ['set', 'no corresponding id', 'alias', 'value'] manager.process_server(args) mock_getby.assert_called_once_with('no corresponding id') mock_print.assert_called_once_with('No server "no corresponding id"')
def plant_server(self, servers): # Write data to fake fs file = jsonpickle.decode(DATA) file['server_registry'] = servers file_str = jsonpickle.encode(file) path = get_config_location() outfile = self.fs.create_file(path, contents=file_str) manager._servers = servers
def test_process_set_type_invokesUpdateServer(self, mock_from, mock_getby, mock_update): self.fs.create_file(get_config_location()) args = ['set', 'bestest server ever', 'type', 'spigot'] planted_server = Server() planted_server.Alias = 'bestest server ever' mock_getby.return_value = planted_server manager.process_server(args) mock_update.assert_called_once() called_args = mock_update.call_args[0] self.assertEqual( 'bestest server ever', called_args[0], 'Update should have been invoked with original identifier') self.assertEqual('spigot', called_args[1].Type, 'Update was invoked with a non-updated object')
def test_process_scan_invokesScan(self, mock_from, mock_scan): self.fs.create_file(get_config_location()) args = ['scan'] manager.process_server(args) mock_scan.assert_called_once_with('')
def test_process_list_invokesList(self, mock_from, mock_list): self.fs.create_file(get_config_location()) args = ['list'] manager.process_server(args) mock_list.assert_called_once()
def test_process_remove_invokesDeregister(self, mock_from, mock_dereg): self.fs.create_file(get_config_location()) args = ['remove', 'my id'] manager.process_server(args) mock_dereg.assert_called_once_with('my id')
def test_process_create_invokesCreate(self, mock_from, mock_create): self.fs.create_file(get_config_location()) args = ['create'] manager.process_server(args) mock_create.assert_called_once() pass