<commit_before>import unittest
import xmlrpclib
from gackshandle import *

class TestGacksHandle(unittest.TestCase):
   def setUp(self):
       pass

   def testCreate(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       self.assertEqual(h.id, "cpu")
       self.assertEqual(h.unitStart, 10)
       self.assertEqual(h.unitStop, 15)
       self.assertEqual(h.timeStart, 20)
       self.assertEqual(h.timeStop, 25)

   def testAsString(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       s = h.as_string()
       self.assertEqual(s, "cpu#10-15#20-25")

   def testLoadFromString(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       s = h.as_string()
       h2 = GacksHandle(string=s)
       self.assertEqual(h.id, h2.id)
       self.assertEqual(h.unitStart, h2.unitStart)
       self.assertEqual(h.unitStop, h2.unitStop)
       self.assertEqual(h.timeStart, h2.timeStart)
       self.assertEqual(h.timeStop, h2.timeStop)

   def testGetQuantity(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       self.assertEqual(h.get_quantity(), 5)

   def testGetDuration(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       self.assertEqual(h.get_duration(), 5)

   def testClone(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       h2 = h.clone()
       self.assertEqual(h.id, h2.id)
       self.assertEqual(h.unitStart, h2.unitStart)
       self.assertEqual(h.unitStop, h2.unitStop)
       self.assertEqual(h.timeStart, h2.timeStart)
       self.assertEqual(h.timeStop, h2.timeStop)

   def testSplit(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       (h1, h2) = h.split(12,23)

       self.assertEqual(h1.id, "cpu")
       self.assertEqual(h1.unitStart, 10)
       self.assertEqual(h1.unitStop, 12)
       self.assertEqual(h1.timeStart, 20)
       self.assertEqual(h1.timeStop, 23)

       self.assertEqual(h2.id, "cpu")
       self.assertEqual(h2.unitStart, 12)
       self.assertEqual(h2.unitStop, 15)
       self.assertEqual(h2.timeStart, 23)
       self.assertEqual(h2.timeStop, 25)

class TestGacksRecord(unittest.TestCase):
   def setUp(self):
       pass
<commit_msg>updates to gacks tests<commit_after>import unittest
import xmlrpclib
from gackshandle import *

class TestGacksHandle(unittest.TestCase):
   def setUp(self):
       pass

   def testCreate(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       self.assertEqual(h.id, "cpu")
       self.assertEqual(h.unitStart, 10)
       self.assertEqual(h.unitStop, 15)
       self.assertEqual(h.timeStart, 20)
       self.assertEqual(h.timeStop, 25)

   def testAsString(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       s = h.as_string()
       self.assertEqual(s, "cpu#10-15#20-25")

   def testLoadFromString(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       s = h.as_string()
       h2 = GacksHandle(string=s)
       self.assertEqual(h.id, h2.id)
       self.assertEqual(h.unitStart, h2.unitStart)
       self.assertEqual(h.unitStop, h2.unitStop)
       self.assertEqual(h.timeStart, h2.timeStart)
       self.assertEqual(h.timeStop, h2.timeStop)

   def testGetQuantity(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       self.assertEqual(h.get_quantity(), 5)

   def testGetDuration(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       self.assertEqual(h.get_duration(), 5)

   def testClone(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       h2 = h.clone()
       self.assertEqual(h.id, h2.id)
       self.assertEqual(h.unitStart, h2.unitStart)
       self.assertEqual(h.unitStop, h2.unitStop)
       self.assertEqual(h.timeStart, h2.timeStart)
       self.assertEqual(h.timeStop, h2.timeStop)

   def testSplitUnit(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       parts = h.split_unit(12)
       h1 = parts[0]
       h2 = parts[1]

       self.assertEqual(h1.id, "cpu")
       self.assertEqual(h1.unitStart, 10)
       self.assertEqual(h1.unitStop, 12)
       self.assertEqual(h1.timeStart, 20)
       self.assertEqual(h1.timeStop, 25)

       self.assertEqual(h2.id, "cpu")
       self.assertEqual(h2.unitStart, 12)
       self.assertEqual(h2.unitStop, 15)
       self.assertEqual(h2.timeStart, 20)
       self.assertEqual(h2.timeStop, 25)

   def testSplitTime(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)
       parts = h.split_time(23)
       h1 = parts[0]
       h2 = parts[1]

       self.assertEqual(h1.id, "cpu")
       self.assertEqual(h1.unitStart, 10)
       self.assertEqual(h1.unitStop, 15)
       self.assertEqual(h1.timeStart, 20)
       self.assertEqual(h1.timeStop, 23)

       self.assertEqual(h2.id, "cpu")
       self.assertEqual(h2.unitStart, 10)
       self.assertEqual(h2.unitStop, 15)
       self.assertEqual(h2.timeStart, 23)
       self.assertEqual(h2.timeStop, 25)

   def testSplitSubset(self):
       h = GacksHandle("cpu", 10, 15, 20, 25)

       # split out a subset right in the middle
       parts = h.clone().split_subset(12, 13, 22, 23)

       self.assertEqual(len(parts), 5)
       self.assert_(find_handle_in_list(parts, 10, 12, 20, 25)) # h1
       self.assert_(find_handle_in_list(parts, 12, 13, 20, 22)) # h2
       self.assert_(find_handle_in_list(parts, 12, 13, 23, 25)) # h3
       self.assert_(find_handle_in_list(parts, 13, 15, 20, 25)) # h4
       self.assert_(find_handle_in_list(parts, 12, 13, 22, 23)) # s

       # split out a subset in the top left corner
       parts = h.clone().split_subset(10, 13, 20, 23)

       self.assertEqual(len(parts), 3)
       self.assert_(find_handle_in_list(parts, 10, 13, 23, 25)) # h3
       self.assert_(find_handle_in_list(parts, 13, 15, 20, 25)) # h4
       self.assert_(find_handle_in_list(parts, 10, 13, 20, 23)) # s

       # split out a subset in the bottom right corner
       parts = h.clone().split_subset(12, 15, 22, 25)

       self.assertEqual(len(parts), 3)
       self.assert_(find_handle_in_list(parts, 10, 12, 20, 25)) # h1
       self.assert_(find_handle_in_list(parts, 12, 15, 20, 22)) # h2
       self.assert_(find_handle_in_list(parts, 12, 15, 22, 25)) # s

class TestGacksRecord(unittest.TestCase):
   def setUp(self):
       pass

{'fraction_non_alphanumeric': 0.13617786496648684, 'fraction_numerical': 0.0665358836030734, 'mean_word_length': 2.781211372064277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5686181', 'n_tokens_mistral': 2501, 'n_tokens_neox': 2148, 'n_words': 441}