def test_make_HTML_table(self):
        """make_HTML_table should Make HTML tables for one set charts"""

        #test pie charts
        fracs_labels_other,fracs_labels,all_counts,other_cat,red,other_frac = \
                                        get_fracs(self.counts1,5,10,'pie')

        img_data = make_HTML_table("Phylum",other_frac,10,red,other_cat,\
                                   fracs_labels_other,fracs_labels,\
                                   self.dir_path,all_counts,1,self.prefs,\
                                   self.color_prefs,'black','white','pie',\
                                   'Test1',\
                                   self.generate_image_type,self.plot_width,\
                                   self.plot_height,self.bar_width,self.dpi,0,\
                                   'categorical',False,False)
        
        self.assertEqual(len(img_data),2)
        
        #test area charts
        fracs_labels_other,fracs_labels,all_counts,other_cat,red,other_frac = \
                                        get_fracs(self.counts1,5,10,'area')

        img_data = make_HTML_table("Phylum",other_frac,10,red,other_cat,\
                                   fracs_labels_other,fracs_labels,\
                                   self.dir_path,all_counts,1,self.prefs,\
                                   self.color_prefs,'black','white','pie',\
                                   'Test1',\
                                   self.generate_image_type,self.plot_width,\
                                   self.plot_height,self.bar_width,self.dpi,0,\
                                   'categorical',False,False)
        
        self.assertEqual(len(img_data),2)
        
        #test bar charts
        fracs_labels_other,fracs_labels,all_counts,other_cat,red,other_frac = \
                                        get_fracs(self.counts1,5,10,'bar')

        img_data = make_HTML_table("Phylum",other_frac,10,red,other_cat,\
                                   fracs_labels_other,fracs_labels,\
                                   self.dir_path,all_counts,1,self.prefs,\
                                   self.color_prefs,'black','white','pie',\
                                   'Test1',\
                                   self.generate_image_type,self.plot_width,\
                                   self.plot_height,self.bar_width,self.dpi,0,\
                                   'categorical',False,False)
        
        self.assertEqual(len(img_data),2)
        self._paths_to_clean_up = ["/tmp/qiimewebfiles/charts/"+f \
                                  for f in listdir("/tmp/qiimewebfiles/charts")]
示例#2
0
    def test_make_HTML_table(self):
        """make_HTML_table should Make HTML tables for one set charts"""

        # test pie charts
        fracs_labels_other, fracs_labels, all_counts, other_cat, red, other_frac = get_fracs(self.counts1, 5, 10, "pie")

        img_data = make_HTML_table(
            "Phylum",
            other_frac,
            10,
            red,
            other_cat,
            fracs_labels_other,
            fracs_labels,
            self.dir_path,
            all_counts,
            1,
            self.prefs,
            self.color_prefs,
            "black",
            "white",
            "pie",
            "Test1",
            self.generate_image_type,
            self.plot_width,
            self.plot_height,
            self.bar_width,
            self.dpi,
            0,
            "categorical",
            False,
        )

        self.assertEqual(len(img_data), 2)

        # test area charts
        fracs_labels_other, fracs_labels, all_counts, other_cat, red, other_frac = get_fracs(
            self.counts1, 5, 10, "area"
        )

        img_data = make_HTML_table(
            "Phylum",
            other_frac,
            10,
            red,
            other_cat,
            fracs_labels_other,
            fracs_labels,
            self.dir_path,
            all_counts,
            1,
            self.prefs,
            self.color_prefs,
            "black",
            "white",
            "pie",
            "Test1",
            self.generate_image_type,
            self.plot_width,
            self.plot_height,
            self.bar_width,
            self.dpi,
            0,
            "categorical",
            False,
        )

        self.assertEqual(len(img_data), 2)

        # test bar charts
        fracs_labels_other, fracs_labels, all_counts, other_cat, red, other_frac = get_fracs(self.counts1, 5, 10, "bar")

        img_data = make_HTML_table(
            "Phylum",
            other_frac,
            10,
            red,
            other_cat,
            fracs_labels_other,
            fracs_labels,
            self.dir_path,
            all_counts,
            1,
            self.prefs,
            self.color_prefs,
            "black",
            "white",
            "pie",
            "Test1",
            self.generate_image_type,
            self.plot_width,
            self.plot_height,
            self.bar_width,
            self.dpi,
            0,
            "categorical",
            False,
        )

        self.assertEqual(len(img_data), 2)
        self._paths_to_clean_up = ["/tmp/qiimewebfiles/charts/" + f for f in listdir("/tmp/qiimewebfiles/charts")]
    def test_get_fracs(self):
        """"get_fracs should Return fractions for matplotlib chart"""

        #test the pie charts
        exp_all_counts=[DATA_HTML%("4",(4.0/10)*100,'a<br>g','h', 'h',"a;g;h"),\
                        DATA_HTML%('3',(3.0/10)*100,'d<br>e','f', 'f',"d;e;f"),\
                        DATA_HTML%('2',(2.0/10)*100,'d<br>e','i', 'i',"d;e;i"),\
                        DATA_HTML%('1',(1.0/10)*100,'a<br>b','c', 'c',"a;b;c")]
        
        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,5,10,'pie')
        
        self.assertEqual(fracs_labels_other,[("a;b;c",1.0/10),("a;g;h",4.0/10),\
                                             ("d;e;f",3.0/10),("d;e;i",2.0/10)])
        self.assertEqual(fracs_labels,[])
        self.assertEqual(all_counts,exp_all_counts)
        
        self.assertEqual(other_cat,0)
        self.assertEqual(red,10)
        self.assertEqual(other_frac,0)

        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,3,10,'pie')
        
        self.assertEqual(fracs_labels_other,[("a;g;h",4.0/10),("d;e;f",3.0/10)])
        self.assertEqual(fracs_labels,[("a;g;h",4.0/7),("d;e;f",3.0/7)])

        self.assertEqual(all_counts,exp_all_counts)
        self.assertEqual(other_cat,2)
        self.assertEqual(red,7)
        self.assertEqual(other_frac,3.0/10)
        
        #test the area charts
        exp_all_counts=['4', '3', '2', '1']
        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,5,10,'area')
        
        self.assertEqual(fracs_labels_other,[("a;b;c",1.0/10),("a;g;h",4.0/10),\
                                             ("d;e;f",3.0/10),("d;e;i",2.0/10)])
        self.assertEqual(fracs_labels,[])
        self.assertEqual(all_counts,exp_all_counts)
        
        self.assertEqual(other_cat,0)
        self.assertEqual(red,10)
        self.assertEqual(other_frac,0)

        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,3,10,'area')
        
        self.assertEqual(fracs_labels_other,[("a;g;h",4.0/10),("d;e;f",3.0/10),\
                                            ('d;e;i',2.0/10)])
        self.assertEqual(fracs_labels,[("a;g;h",8.0/18),("d;e;f",6.0/18)])

        self.assertEqual(all_counts,exp_all_counts)
        self.assertEqual(other_cat,2)
        self.assertEqual(red,9)
        self.assertEqual(other_frac,3.0/10)
        
        #test bar charts
        exp_all_counts=['4', '3', '2', '1']
        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,5,10,'bar')
        
        self.assertEqual(fracs_labels_other,[("a;b;c",1.0/10),("a;g;h",4.0/10),\
                                             ("d;e;f",3.0/10),("d;e;i",2.0/10)])
        self.assertEqual(fracs_labels,[])
        self.assertEqual(all_counts,exp_all_counts)
        
        self.assertEqual(other_cat,0)
        self.assertEqual(red,10)
        self.assertEqual(other_frac,0)

        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,3,10,'bar')
        
        self.assertEqual(fracs_labels_other,[("a;g;h",4.0/10),("d;e;f",3.0/10),\
                                            ('d;e;i',2.0/10)])
        self.assertEqual(fracs_labels,[("a;g;h",8.0/18),("d;e;f",6.0/18)])

        self.assertEqual(all_counts,exp_all_counts)
        self.assertEqual(other_cat,2)
        self.assertEqual(red,9)
        self.assertEqual(other_frac,3.0/10)
        
        self._paths_to_clean_up = ["/tmp/qiimewebfiles/charts/"+f \
                                  for f in listdir("/tmp/qiimewebfiles/charts")]
示例#4
0
    def test_get_fracs(self):
        """"get_fracs should Return fractions for matplotlib chart"""

        # test the pie charts
        exp_all_counts = [
            DATA_HTML % ((4.0 / 10) * 100.0, "a<br>g", "h", "h", "a;g;h"),
            DATA_HTML % ((3.0 / 10) * 100, "d<br>e", "f", "f", "d;e;f"),
            DATA_HTML % ((2.0 / 10) * 100, "d<br>e", "i", "i", "d;e;i"),
            DATA_HTML % ((1.0 / 10) * 100, "a<br>b", "c", "c", "a;b;c"),
        ]

        fracs_labels_other, fracs_labels, all_counts, other_cat, red, other_frac = get_fracs(self.counts1, 5, 10, "pie")

        self.assertEqual(
            fracs_labels_other, [("a;b;c", 1.0 / 10), ("a;g;h", 4.0 / 10), ("d;e;f", 3.0 / 10), ("d;e;i", 2.0 / 10)]
        )
        self.assertEqual(fracs_labels, [])
        self.assertEqual(all_counts, exp_all_counts)

        self.assertEqual(other_cat, 0)
        self.assertEqual(red, 10)
        self.assertEqual(other_frac, 0)

        fracs_labels_other, fracs_labels, all_counts, other_cat, red, other_frac = get_fracs(self.counts1, 3, 10, "pie")

        self.assertEqual(fracs_labels_other, [("a;g;h", 4.0 / 10), ("d;e;f", 3.0 / 10)])
        self.assertEqual(fracs_labels, [("a;g;h", 4.0 / 7), ("d;e;f", 3.0 / 7)])

        self.assertEqual(all_counts, exp_all_counts)
        self.assertEqual(other_cat, 2)
        self.assertEqual(red, 7)
        self.assertEqual(other_frac, 3.0 / 10)

        # test the area charts
        exp_all_counts = ["4", "3", "2", "1"]
        fracs_labels_other, fracs_labels, all_counts, other_cat, red, other_frac = get_fracs(
            self.counts1, 5, 10, "area"
        )

        self.assertEqual(
            fracs_labels_other, [("a;b;c", 1.0 / 10), ("a;g;h", 4.0 / 10), ("d;e;f", 3.0 / 10), ("d;e;i", 2.0 / 10)]
        )
        self.assertEqual(fracs_labels, [])
        self.assertEqual(all_counts, exp_all_counts)

        self.assertEqual(other_cat, 0)
        self.assertEqual(red, 10)
        self.assertEqual(other_frac, 0)

        fracs_labels_other, fracs_labels, all_counts, other_cat, red, other_frac = get_fracs(
            self.counts1, 3, 10, "area"
        )

        self.assertEqual(fracs_labels_other, [("a;g;h", 4.0 / 10), ("d;e;f", 3.0 / 10), ("d;e;i", 2.0 / 10)])
        self.assertEqual(fracs_labels, [("a;g;h", 8.0 / 18), ("d;e;f", 6.0 / 18)])

        self.assertEqual(all_counts, exp_all_counts)
        self.assertEqual(other_cat, 2)
        self.assertEqual(red, 9)
        self.assertEqual(other_frac, 3.0 / 10)

        # test bar charts
        exp_all_counts = ["4", "3", "2", "1"]
        fracs_labels_other, fracs_labels, all_counts, other_cat, red, other_frac = get_fracs(self.counts1, 5, 10, "bar")

        self.assertEqual(
            fracs_labels_other, [("a;b;c", 1.0 / 10), ("a;g;h", 4.0 / 10), ("d;e;f", 3.0 / 10), ("d;e;i", 2.0 / 10)]
        )
        self.assertEqual(fracs_labels, [])
        self.assertEqual(all_counts, exp_all_counts)

        self.assertEqual(other_cat, 0)
        self.assertEqual(red, 10)
        self.assertEqual(other_frac, 0)

        fracs_labels_other, fracs_labels, all_counts, other_cat, red, other_frac = get_fracs(self.counts1, 3, 10, "bar")

        self.assertEqual(fracs_labels_other, [("a;g;h", 4.0 / 10), ("d;e;f", 3.0 / 10), ("d;e;i", 2.0 / 10)])
        self.assertEqual(fracs_labels, [("a;g;h", 8.0 / 18), ("d;e;f", 6.0 / 18)])

        self.assertEqual(all_counts, exp_all_counts)
        self.assertEqual(other_cat, 2)
        self.assertEqual(red, 9)
        self.assertEqual(other_frac, 3.0 / 10)

        self._paths_to_clean_up = ["/tmp/qiimewebfiles/charts/" + f for f in listdir("/tmp/qiimewebfiles/charts")]