<commit_before>import os
import time
import requests
from urlparse import urljoin
from subprocess import Popen, PIPE
from .warehaus_test_base import WarehausApiTestBase

class ServerTests(WarehausApiTestBase):
    def test_server_operations(self):
        '''Test server type creation, agent downloading and running heartbeat
        for creating servers.
        '''
        with self.temp_lab() as lab:
            server_type_path = self.create_type_object(lab, type_key='builtin-server', slug='srvr',
                                                       name_singular='Server', name_plural='Servers')
            servers_before = self.api_server.get(urljoin(server_type_path, 'objects'))
            self.assertEqual(len(servers_before['objects']), 0)
            agent_code = self.get_agent_code(server_type_path)
            self.run_agent(agent_code)
            servers_after = self.api_server.get(urljoin(server_type_path, 'objects'))
            self.assertEqual(len(servers_after['objects']), 1)
<commit_msg>Test that the agent runs multiple times successfully<commit_after>import os
import time
import requests
from urlparse import urljoin
from subprocess import Popen, PIPE
from .warehaus_test_base import WarehausApiTestBase

class ServerTests(WarehausApiTestBase):
    def test_server_operations(self):
        '''Test server type creation, agent downloading and running heartbeat
        for creating servers.
        '''
        with self.temp_lab() as lab:
            server_type_path = self.create_type_object(lab, type_key='builtin-server', slug='srvr',
                                                       name_singular='Server', name_plural='Servers')
            servers_before = self.api_server.get(urljoin(server_type_path, 'objects'))
            self.assertEqual(len(servers_before['objects']), 0)
            agent_code = self.get_agent_code(server_type_path)
            for _ in xrange(5):
                self.run_agent(agent_code)
                servers_after = self.api_server.get(urljoin(server_type_path, 'objects'))
                self.assertEqual(len(servers_after['objects']), 1)

{'fraction_non_alphanumeric': 0.08705882352941176, 'fraction_numerical': 0.002352941176470588, 'mean_word_length': 2.937037037037037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '809844', 'n_tokens_mistral': 579, 'n_tokens_neox': 569, 'n_words': 126}