Exemple #1
0
class TestBuilderRawMethods(TestCase):
    @classmethod
    def setUp(self):
        self.m = BuildCloth()
        self.content = ['the md5 is ab98a7b91094a4ebd9fc0e1a93e985d6']

    def test_raw_list(self):
        b = 'raw0'
        self.m.raw(lines=self.content, block=b)

        self.assertEqual(self.content, self.m.get_block(b))

    def test_raw_string(self):
        b = 'raw1'

        with self.assertRaises(MalformedRawContent):
            self.m.raw(lines=self.content[0], block=b)

    def test_raw_nested_list(self):
        b = 'raw2'

        with self.assertRaises(MalformedRawContent):
            self.m.raw(lines=[self.content, self.content], block=b)
Exemple #2
0
 def setUp(self):
     self.b = BuildCloth()
Exemple #3
0
 def setUp(self):
     self.argument = [1, 2, 3]
     self.m = BuildCloth(self.argument)
Exemple #4
0
 def setUp(self):
     self.block = 'ab98'
     self.block1 = '98ab'
     self.b = BuildCloth()
     self.content = 'the md5 is ab98a7b91094a4ebd9fc0e1a93e985d6'
Exemple #5
0
class TestBuildClothBlocks(TestCase):
    @classmethod
    def setUp(self):
        self.block = 'ab98'
        self.block1 = '98ab'
        self.b = BuildCloth()
        self.content = 'the md5 is ab98a7b91094a4ebd9fc0e1a93e985d6'

    def test_add_list(self):
        with self.assertRaises(MalformedContent):
            self.b._add_to_builder([self.content, self.content], self.block)

    def test_add_dict(self):
        with self.assertRaises(MalformedContent):
            self.b._add_to_builder({self.block: self.content}, self.block)

    def test_block_in_builder(self):
        self.b._add_to_builder(self.content, self.block)

        self.assertIn(self.block, self.b.builder)

    def test_add_content_to_block(self):
        self.b._add_to_builder(self.content, self.block)

        self.assertEqual([self.content], self.b.builder['_all'])
        self.assertEqual([self.content], self.b.builder[self.block])
        self.assertIsNot([self.content], self.b.builder[self.block])
        self.assertEqual(self.b.builder[self.block], self.b.builder['_all'])

    def test_add_content_to_different_blocks(self):
        self.b._add_to_builder(self.content, self.block)
        self.b._add_to_builder(self.content, self.block1)
        b_block = self.b.get_block(self.block)
        b_block1 = self.b.get_block(self.block1)

        self.assertEqual(b_block, b_block1)
        self.assertIsNot(b_block, b_block1)
        self.assertEqual(b_block + b_block1, self.b.builder['_all'])

    def teset_block_method_empty(self):
        self.b.block('nn')
        self.assertEqual(self.b.get_block('nn'), [])

    def teset_block_method_with_block(self):
        self.b.section_break('test of nested', block='part1')

        self.b.block('part2', self.b.get_block('part1'))

        self.assertEqual(self.get_block('part1'), self.get_block('part2'))
Exemple #6
0
 def setUp(self):
     self.m = BuildCloth()
     self.content = ['the md5 is ab98a7b91094a4ebd9fc0e1a93e985d6']