Beispiel #1
0
 def test_find_language_with_most_bytes(self):
     helloworldpy_filemeta = self.deliverybuilder\
         .add_filemeta(filename='helloworld.py', data='a').filemeta
     helloworldjava_filemeta = self.deliverybuilder\
         .add_filemeta(filename='HelloWorld.java', data='abc').filemeta
     filemetas_by_language = FileMetasByFiletype([helloworldpy_filemeta, helloworldjava_filemeta])
     filemetacollection = filemetas_by_language.find_language_with_most_bytes()
     self.assertEqual(filemetacollection.language, 'java')
     self.assertEqual(filemetacollection.filemetas, [helloworldjava_filemeta])
Beispiel #2
0
    def test_group_by_extension_has_supported_files(self):
        self.deliverybuilder.add_filemeta(filename='helloworld.txt', data='Hello world')
        helloworldpy_filemeta = self.deliverybuilder\
            .add_filemeta(filename='helloworld.py', data='def abc()').filemeta
        helloworldjava_filemeta = self.deliverybuilder\
            .add_filemeta(filename='HelloWorld.java', data='// test').filemeta
        helloworldjava2_filemeta = self.deliverybuilder\
            .add_filemeta(filename='HelloWorld2.java', data='// test2').filemeta

        # filemetas_by_language = DeliveryParser(self.deliverybuilder.delivery)._group_filemetas_by_language()
        filemetas_by_language = FileMetasByFiletype(
            [helloworldpy_filemeta, helloworldjava_filemeta, helloworldjava2_filemeta])
        self.assertEquals(
            set(filemetas_by_language.filemetacollection_by_language.keys()),
            {'java', 'python'})
        self.assertEquals(
            filemetas_by_language['java'].size,
            len('// test') + len('// test2'))
        self.assertEquals(
            filemetas_by_language['python'].size,
            len('def abs()'))
        self.assertEquals(
            filemetas_by_language['java'].filemetas,
            [helloworldjava_filemeta, helloworldjava2_filemeta])
        self.assertEquals(
            filemetas_by_language['python'].filemetas,
            [helloworldpy_filemeta])
Beispiel #3
0
 def test_group_by_extension_no_filemetas(self):
     filemetas_by_language = FileMetasByFiletype([])
     self.assertEquals(len(filemetas_by_language), 0)
Beispiel #4
0
 def test_group_by_extension_no_supported_files(self):
     self.deliverybuilder.add_filemeta(filename='helloworld.txt', data='Hello world')
     filemetas_by_language = FileMetasByFiletype([])
     self.assertEquals(len(filemetas_by_language), 0)
Beispiel #5
0
 def test_get_language_from_filename(self):
     filemetas_by_language = FileMetasByFiletype([])
     self.assertEquals(filemetas_by_language._get_language_from_filename('test.java'), 'java')
     self.assertEquals(filemetas_by_language._get_language_from_filename('test.py'), 'python')