Example #1
0
 def test_unit_test_file(self):
     sample_dataset = 'ABC123'
     sample_dataset_answer = '6'
     sample_ut = biogen.create_unittest_text(self.id, 'sample', sample_dataset, sample_dataset_answer)
     extra_dataset = 'ZZZABC123ZZZ'
     extra_dataset_answer = '12'
     extra_ut = biogen.create_unittest_text(self.id, 'extra', extra_dataset, extra_dataset_answer)
     biogen.create_unittests(self.newpath, self.id, sample_ut, extra_ut)
     test_file_path = os.path.join(self.newpath, 'bio'+biogen.slugify(self.id).lower()+'_test.py')
     self.assertTrue(os.path.isfile(test_file_path))
     with open (test_file_path, "r") as myfile:
       test_contents=myfile.read()
     # Test if tests contain valid strings
     self.assertTrue('import bio' + biogen.slugify(self.id) in test_contents)
     self.assertTrue('bio' + biogen.slugify(self.id) + '.' + 'bio_' + biogen.slugify(self.id) in test_contents)
     self.assertTrue('class Bio' + biogen.slugify(self.id) + 'TestCase(unittest.TestCase)' in test_contents)
Example #2
0
    def test_unit_test_file(self):
        sample_dataset = """ACGTTGCATGTCGCATGATGCATGAGAGCT
4"""
        sample_dataset_answer = """CATG GCAT"""
        sample_ut = biogen.create_unittest_text(self.id, 'sample', sample_dataset, sample_dataset_answer)
        extra_dataset = """CGGAAGCGAGATTCGCGTGGCGTGATTCCGGCGGGCGTGGAGAAGCGAGATTCATTCAAGCCGGGAGGCGTGGCGTGGCGTGGCGTGCGGATTCAAGCCGGCGGGCGTGATTCGAGCGGCGGATTCGAGATTCCGGGCGTGCGGGCGTGAAGCGCGTGGAGGAGGCGTGGCGTGCGGGAGGAGAAGCGAGAAGCCGGATTCAAGCAAGCATTCCGGCGGGAGATTCGCGTGGAGGCGTGGAGGCGTGGAGGCGTGCGGCGGGAGATTCAAGCCGGATTCGCGTGGAGAAGCGAGAAGCGCGTGCGGAAGCGAGGAGGAGAAGCATTCGCGTGATTCCGGGAGATTCAAGCATTCGCGTGCGGCGGGAGATTCAAGCGAGGAGGCGTGAAGCAAGCAAGCAAGCGCGTGGCGTGCGGCGGGAGAAGCAAGCGCGTGATTCGAGCGGGCGTGCGGAAGCGAGCGG
12"""
        extra_dataset_answer = """CGGCGGGAGATT CGGGAGATTCAA CGTGCGGCGGGA CGTGGAGGCGTG CGTGGCGTGCGG GCGTGCGGCGGG GCGTGGAGGCGT GCGTGGCGTGCG GGAGAAGCGAGA GGAGATTCAAGC GGCGGGAGATTC GGGAGATTCAAG GTGCGGCGGGAG TGCGGCGGGAGA"""
        extra_ut = biogen.create_unittest_text(self.id, 'extra', extra_dataset, extra_dataset_answer)
        biogen.create_unittests(self.newpath, self.id, sample_ut, extra_ut)
        test_file_path = os.path.join(self.newpath, 'bio'+biogen.slugify(self.id).lower()+'_test.py')
        self.assertTrue(os.path.isfile(test_file_path))
        with open (test_file_path, "r") as myfile:
          test_contents=myfile.read()
        # Test if tests contain valid strings
        self.assertTrue('import bio' + biogen.slugify(self.id) in test_contents)
        self.assertTrue('bio' + biogen.slugify(self.id) + '.' + 'bio_' + biogen.slugify(self.id) in test_contents)
        self.assertTrue('class Bio' + biogen.slugify(self.id) + 'TestCase(unittest.TestCase)' in test_contents)