def test_add_aggregate(self):
        # end
        
        # check nothing is there
        self.assertEqual(SSHAggregate.objects.count(), 0)
        # end
        
        # get private key as string
        pkey_f = StringIO()
        self.test_key.write_private_key(pkey_f)
        pkey = pkey_f.getvalue()
        pkey_f.close()
        # end
        
        # Add the aggregate
        response = test_get_and_post_form(
            self.client,
            url=reverse(aggregate_crud),
            params=dict(
                name="Test Aggregate",
                description="Aggregate on localhost",
                location="right here",
                admin_username=getpass.getuser(),
                private_key=pkey,
                add_user_command="sh -c 'echo %(username)s >> " +
                    Tests.CREATED_USER_FNAME + "'",
                del_user_command="sh -c 'echo %(username)s >> " +
                    Tests.DELETED_USER_FNAME + "'",
                add_pubkey_user_command="sh -c 'echo %(pubkey)s >> " +
                    Tests.PUBKEY_USER_FNAME + "'",
            ),
        )
        self.assertEqual(SSHAggregate.objects.count(), 1)
        # end
        
        # where do we go next?
        next_url = reverse(aggregate_add_servers, args=[1])
        self.assertRedirects(
            response, next_url)
        # end
        
        # Add the localhost as a server
        response = test_get_and_post_form(
            self.client,
            url=next_url,
            params={
                "form-0-name": "localhost",
                "form-0-ip_address": "127.0.0.1",
                "form-0-ssh_port": "22",
            },
        )
        # end
        
        # check that localhost added
        self.assertRedirects(
            response, reverse(aggregate_add_servers, args=[1]),
            msg_prefix="Response was %s" % response)
        self.assertEqual(SSHServer.objects.count(), 1)
        # end
        
    # slice tests
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/doc/expedient/source/developer/sshaggregate/tests.py/Tests.test_add_aggregate/original