<commit_before>import unittest
import time
import Queue
import logging
import sys

sys.path.append('../space_machines')
sys.path.append('space_machines')
from door import DoorState

class DoorTests(unittest.TestCase):

  def setUp(self):
    logging.basicConfig(level=logging.WARN)
    self.doorstate = DoorState()
    self.doorstate.setup(None, name="TEST_DOOR")
    self.doorstate.start()
    
  def test_quick_open_close(self):
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED - Nope")
    self.doorstate.send_message({"event": "VALID_KEY"})
    time.sleep(0.1)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_UNLOCKING")
    self.doorstate.send_message({"event":"DOOR_OPENED"})
    time.sleep(0.1)
    self.assertEqual(self.doorstate.current_state(), "OPEN_UNLOCKING")
    self.doorstate.send_message({"event":"DOOR_CLOSED"})
    time.sleep(0.1)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")

  def test_open_wait_close(self):
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")
    self.doorstate.send_message({"event": "VALID_KEY"})
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_UNLOCKING")
    self.doorstate.send_message({"event":"DOOR_OPENED"})
    time.sleep(0.2)
    self.assertEqual(self.doorstate.current_state(), "OPEN_UNLOCKING")
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "OPEN_LOCKED")
    self.doorstate.send_message({"event":"DOOR_CLOSED"})
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")

  def test_open_longwait_close(self):
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")
    self.doorstate.send_message({"event": "VALID_KEY"})
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_UNLOCKING")
    self.doorstate.send_message({"event":"DOOR_OPENED"})
    time.sleep(20)
    self.assertEqual(self.doorstate.current_state(), "STUCK_OPEN")
    self.doorstate.send_message({"event":"DOOR_CLOSED"})
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")

  def test_force_open(self):
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")
    self.doorstate.send_message({"event":"DOOR_OPENED"})
    time.sleep(0.2)
    self.assertEqual(self.doorstate.current_state(), "FORCED_OPEN")
    self.doorstate.send_message({"event":"DOOR_CLOSED"})
    time.sleep(0.2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")

if __name__ == '__main__':
    unittest.main()<commit_msg>trying to export the test results as xml<commit_after>import unittest
import time
import Queue
import logging
import sys
import xmlrunner

sys.path.append('../space_machines')
sys.path.append('space_machines')
from door import DoorState

class DoorTests(unittest.TestCase):

  def setUp(self):
    logging.basicConfig(level=logging.WARN)
    self.doorstate = DoorState()
    self.doorstate.setup(None, name="TEST_DOOR")
    self.doorstate.start()
    
  def test_quick_open_close(self):
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")
    self.doorstate.send_message({"event": "VALID_KEY"})
    time.sleep(0.1)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_UNLOCKING")
    self.doorstate.send_message({"event":"DOOR_OPENED"})
    time.sleep(0.1)
    self.assertEqual(self.doorstate.current_state(), "OPEN_UNLOCKING")
    self.doorstate.send_message({"event":"DOOR_CLOSED"})
    time.sleep(0.1)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")

  def test_open_wait_close(self):
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")
    self.doorstate.send_message({"event": "VALID_KEY"})
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_UNLOCKING")
    self.doorstate.send_message({"event":"DOOR_OPENED"})
    time.sleep(0.2)
    self.assertEqual(self.doorstate.current_state(), "OPEN_UNLOCKING")
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "OPEN_LOCKED")
    self.doorstate.send_message({"event":"DOOR_CLOSED"})
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")

  def test_open_longwait_close(self):
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")
    self.doorstate.send_message({"event": "VALID_KEY"})
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_UNLOCKING")
    self.doorstate.send_message({"event":"DOOR_OPENED"})
    time.sleep(20)
    self.assertEqual(self.doorstate.current_state(), "STUCK_OPEN")
    self.doorstate.send_message({"event":"DOOR_CLOSED"})
    time.sleep(2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")

  def test_force_open(self):
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")
    self.doorstate.send_message({"event":"DOOR_OPENED"})
    time.sleep(0.2)
    self.assertEqual(self.doorstate.current_state(), "FORCED_OPEN")
    self.doorstate.send_message({"event":"DOOR_CLOSED"})
    time.sleep(0.2)
    self.assertEqual(self.doorstate.current_state(), "CLOSED_LOCKED")

if __name__ == '__main__':
    unittest.main()
    unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
{'fraction_non_alphanumeric': 0.14990512333965844, 'fraction_numerical': 0.007210626185958254, 'mean_word_length': 5.435897435897436, 'pattern_counts': {'":': 22, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, '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': '797464', 'n_tokens_mistral': 1828, 'n_tokens_neox': 1818, 'n_words': 202}