def test_encode_without_permutation(self):
        corpus = 'hi my name is pat what is your name'
        d = DeLorean(corpus, bucket_size=2, n=1)

        self.assertEqual(d.encode_without_permutation('00'), ['hi', 'name'])
        self.assertEqual(d.encode_without_permutation('10'), ['my', 'name'])
        self.assertEqual(d.encode_without_permutation('11'), ['my', 'is'])
    def test_encode_without_permutation_padding(self):
        corpus = 'hi my name is pat what is your name please tell me'
        d = DeLorean(corpus, bucket_size=4, n=2)

        self.assertEqual(d.encode_without_permutation('0'), ['hi'])
        self.assertEqual(d.encode_without_permutation('1'), ['name'])
        self.assertEqual(d.encode_without_permutation('000'), ['hi', 'pat'])
        self.assertEqual(d.encode_without_permutation('001'), ['hi', 'your'])
 def test_end_to_end(self):
     with open('script.txt', 'r') as f:
         corpus = f.read()
     d = DeLorean(corpus)
     for i in range(12):
         inp = ''.join(random.choice(['0', '1']) for _ in range(d.max_bits))
         inp = inp[:-i]
         encoded = d.encode_without_permutation(inp)
         random.shuffle(encoded)
         decoded = d.decode(encoded)
         while len(inp) % d.n != 0:
             inp += '0'
         self.assertEqual(decoded, inp)