def test_copy_existing_group(self):
    'Test user is prompted to continue if destination group exists and is not empty'
    source_label = 'source_copy_existing_group'
    dest_label = 'dest_copy_existing_group'
    calc_s1 = orm.CalculationNode().store()
    calc_s2 = orm.CalculationNode().store()
    nodes_source_group = {str(node.uuid) for node in [calc_s1, calc_s2]}
    source_group = orm.Group(label=source_label).store()
    source_group.add_nodes([calc_s1, calc_s2])
    options = [source_label, dest_label]
    result = self.cli_runner.invoke(group_copy, options)
    self.assertClickResultNoException(result)
    self.assertIn('Success: Nodes copied from group<{}> to group<{}>'.format(source_label, dest_label), result.output, result.exception)
    dest_group = orm.load_group(label=dest_label)
    self.assertEqual(dest_group.count(), 2)
    nodes_dest_group = {str(node.uuid) for node in dest_group.nodes}
    self.assertSetEqual(nodes_source_group, nodes_dest_group)
    result = self.cli_runner.invoke(group_copy, options)
    self.assertIsNotNone(result.exception, result.output)
    self.assertIn('Warning: Destination group<{}> already exists and is not empty.'.format(dest_label), result.output, result.exception)
    dest_group = orm.load_group(label=dest_label)
    self.assertEqual(dest_group.count(), 2)
    nodes_dest_group = {str(node.uuid) for node in dest_group.nodes}
    self.assertSetEqual(nodes_source_group, nodes_dest_group)
Test user is prompted to continue if destination group exists and is not empty
def test_copy_existing_group(self):
    
    source_label = 'source_copy_existing_group'
    dest_label = 'dest_copy_existing_group'
    calc_s1 = orm.CalculationNode().store()
    calc_s2 = orm.CalculationNode().store()
    nodes_source_group = {str(node.uuid) for node in [calc_s1, calc_s2]}
    source_group = orm.Group(label=source_label).store()
    source_group.add_nodes([calc_s1, calc_s2])
    options = [source_label, dest_label]
    result = self.cli_runner.invoke(group_copy, options)
    self.assertClickResultNoException(result)
    self.assertIn('Success: Nodes copied from group<{}> to group<{}>'.format(source_label, dest_label), result.output, result.exception)
    dest_group = orm.load_group(label=dest_label)
    self.assertEqual(dest_group.count(), 2)
    nodes_dest_group = {str(node.uuid) for node in dest_group.nodes}
    self.assertSetEqual(nodes_source_group, nodes_dest_group)
    result = self.cli_runner.invoke(group_copy, options)
    self.assertIsNotNone(result.exception, result.output)
    self.assertIn('Warning: Destination group<{}> already exists and is not empty.'.format(dest_label), result.output, result.exception)
    dest_group = orm.load_group(label=dest_label)
    self.assertEqual(dest_group.count(), 2)
    nodes_dest_group = {str(node.uuid) for node in dest_group.nodes}
    self.assertSetEqual(nodes_source_group, nodes_dest_group)