<commit_before>import web_common
import unittest
from selenium import webdriver

EXPECTED_JOB_HEADERS = ['Group', 'Jobs', 'Idle', 'Running', 'Completed', 'Held', 'Other', 'Foreign', 'Condor FQDN', 'Condor Status', 'Agent Status', 'Condor Cert', 'Worker Cert']
EXPECTED_VM_HEADERS = ['Group', 'Clouds', 'RT (μs)', 'VMs', 'Starting', 'Unreg.', 'Idle', 'Running', 'Retiring', 'Manual', 'Error', 'Slots', 'Busy', 'Idle', 'Used', 'Limit', 'RAM']
EXPECTED_SYSTEM_HEADERS = ['CS system services', 'CS system resources']
EXPECTED_SYSTEM_LABELS = ['status', 'main', 'database', 'rabbitmq', 'openstack', 'jobs', 'machines', 'timeseries', 'ec2', 'watch', 'VMdata', 'Cert Info']

class TestStatus(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        settings = web_common.setup()
        cls.driver = webdriver.Firefox(webdriver.FirefoxProfile(settings['web']['firefox_profile']))
        cls.driver.get('{}/cloud/status'.format(settings['address']))
        cls.driver.switch_to.alert.accept()

    def test_status_display(self):
        status_tables = self.driver.find_elements_by_class_name('status-tables')
        system_table = self.driver.find_element_by_id('system-services')
        self.assertEqual(len(status_tables), 2)
        job_table, vm_table = status_tables
        job_headers = [elem.get_attribute('innerHTML') for elem in job_table.find_elements_by_tag_name('th')]
        self.assertEqual(job_headers, EXPECTED_JOB_HEADERS)
        vm_headers = [elem.get_attribute('innerHTML') for elem in vm_table.find_elements_by_tag_name('th')]
        self.assertEqual(vm_headers, EXPECTED_VM_HEADERS)
        system_headers = [elem.get_attribute('innerHTML') for elem in system_table.find_elements_by_tag_name('th')]
        self.assertEqual(system_headers, EXPECTED_SYSTEM_HEADERS)
        system_rows = system_table.find_elements_by_tag_name('tr')
        self.assertEqual(len(system_rows), 3)
        system_labels = [elem.get_attribute('innerHTML') for elem in system_rows[2].find_elements_by_tag_name('td')]
        self.assertEqual(system_labels, EXPECTED_SYSTEM_LABELS)
        refresh_buttons = self.driver.find_elements_by_class_name('refresh-button')
        self.assertEqual(len(refresh_buttons), 1)

    @classmethod
    def tearDownClass(cls):
        cls.driver.close()
<commit_msg>[WIP] Debug test_status.<commit_after>import web_common
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.ui import WebDriverWait

EXPECTED_NAV_LINKS = [('/cloud/status/', 'Status'), ('/cloud/list/', 'Clouds'), ('/alias/list/', 'Aliases'), ('/group/defaults/', 'Defaults'), ('/images/', 'Images'), ('/keypairs/', 'Keys'), ('/user/list/', 'Users'), ('/group/list/', 'Groups'), ('/server/config/', 'Config'), ('/user/settings/', 'User Settings'), ('/settings/log-out', 'Log out')]
EXPECTED_JOB_HEADERS = ['Group', 'Jobs', 'Idle', 'Running', 'Completed', 'Held', 'Other', '&nbsp;', 'Foreign', '&nbsp;', 'Condor FQDN', 'Condor Status', 'Agent Status', 'Condor Cert', 'Worker Cert']
EXPECTED_VM_HEADERS = ['Group', 'Clouds', 'RT (μs)', '&nbsp;', 'VMs', 'Starting', 'Unreg.', 'Idle', 'Running', 'Retiring', 'Manual', 'Error', '&nbsp;', 'Slots', 'Busy', 'Idle', '&nbsp;', 'Used', 'Limit', 'RAM']
EXPECTED_SYSTEM_HEADERS = ['CS system services', '&nbsp;', 'CS system resources']
EXPECTED_SYSTEM_LABELS = ['status', 'main', 'database', 'rabbitmq', 'openstack', 'jobs', 'machines', 'timeseries', 'ec2', 'watch', 'VMdata', '<nobr>Cert Info</nobr>', '&nbsp;', 'LOAD', 'RAM', 'SWAP', 'DISK']

class TestStatus(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.settings = web_common.setup()
        cls.driver = webdriver.Firefox(webdriver.FirefoxProfile(cls.settings['web']['firefox_profile']))
        cls.driver.get('{}/cloud/status'.format(cls.settings['address']))
        cls.driver.switch_to.alert.accept()
        WebDriverWait(cls.driver, 20).until(expected_conditions.presence_of_element_located((By.ID, 'system-services')))

    def test_status_display(self):
        top_navs = self.driver.find_elements_by_class_name('top-nav')
        self.assertEqual(len(top_navs), 1)
        nav_links = [(re.match(cls.settings['address'] + r'([^?]+)', elem.get_attribute('href'))[1], elem.get_attribute('innerHTML')) for elem in top_navs[0].find_elements_by_tag_name('a')]
        self.assertEqual(nav_links, EXPECTED_NAV_LINKS)
        status_tables = self.driver.find_elements_by_class_name('status-table')
        system_table = self.driver.find_element_by_id('system-services')
        self.assertEqual(len(status_tables), 2)
        job_table, vm_table = status_tables
        job_headers = [elem.get_attribute('innerHTML') for elem in job_table.find_elements_by_tag_name('th')]
        self.assertEqual(job_headers, EXPECTED_JOB_HEADERS)
        # vm_headers = [elem.get_attribute('innerHTML') for elem in vm_table.find_elements_by_tag_name('th')]
        # self.assertEqual(vm_headers, EXPECTED_VM_HEADERS)
        system_headers = [elem.get_attribute('innerHTML') for elem in system_table.find_elements_by_tag_name('th')]
        self.assertEqual(system_headers, EXPECTED_SYSTEM_HEADERS)
        system_rows = system_table.find_elements_by_tag_name('tr')
        self.assertEqual(len(system_rows), 3)
        system_labels = [elem.get_attribute('innerHTML') for elem in system_rows[2].find_elements_by_tag_name('td')]
        self.assertEqual(system_labels, EXPECTED_SYSTEM_LABELS)
        refresh_buttons = self.driver.find_elements_by_class_name('refresh-button')
        self.assertEqual(len(refresh_buttons), 1)

    @classmethod
    def tearDownClass(cls):
        cls.driver.close()

{'fraction_non_alphanumeric': 0.16061185468451242, 'fraction_numerical': 0.002607335303320007, 'mean_word_length': 5.134328358208955, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4319102', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1850, 'n_words': 334}