当前位置: 首页>>代码示例>>Python>>正文


Python SampleTemplate._get_sample_ids方法代码示例

本文整理汇总了Python中qiita_db.metadata_template.SampleTemplate._get_sample_ids方法的典型用法代码示例。如果您正苦于以下问题:Python SampleTemplate._get_sample_ids方法的具体用法?Python SampleTemplate._get_sample_ids怎么用?Python SampleTemplate._get_sample_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qiita_db.metadata_template.SampleTemplate的用法示例。


在下文中一共展示了SampleTemplate._get_sample_ids方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestSampleTemplate

# 需要导入模块: from qiita_db.metadata_template import SampleTemplate [as 别名]
# 或者: from qiita_db.metadata_template.SampleTemplate import _get_sample_ids [as 别名]

#.........这里部分代码省略.........
                "Test Sample 2"],
               [2, "Sample3", "location1", True, True, "type1", 1,
                datetime(2014, 5, 29, 12, 24, 51), "NotIdentified",
                "Test Sample 3"]]
        self.assertEqual(obs, exp)

        # The relevant rows have been added to the study_sample_columns
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.study_sample_columns WHERE study_id=2")
        # study_id, column_name, column_type
        exp = [[2, "str_column", "varchar"]]
        self.assertEqual(obs, exp)

        # The new table exists
        self.assertTrue(exists_table("sample_2", self.conn_handler))

        # The new table hosts the correct values
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.sample_2")
        # sample_id, str_column
        exp = [['Sample1', "Value for sample 1"],
               ['Sample2', "Value for sample 2"],
               ['Sample3', "Value for sample 3"]]
        self.assertEqual(obs, exp)

    def test_exists_true(self):
        """Exists returns true when the SampleTemplate already exists"""
        self.assertTrue(SampleTemplate.exists(self.test_study))

    def test_exists_false(self):
        """Exists returns false when the SampleTemplate does not exists"""
        self.assertFalse(SampleTemplate.exists(self.new_study))

    def test_get_sample_ids(self):
        """get_sample_ids returns the correct set of sample ids"""
        obs = self.tester._get_sample_ids(self.conn_handler)
        self.assertEqual(obs, self.exp_sample_ids)

    def test_len(self):
        """Len returns the correct number of sample ids"""
        self.assertEqual(len(self.tester), 27)

    def test_getitem(self):
        """Get item returns the correct sample object"""
        obs = self.tester['SKM7.640188']
        exp = Sample('SKM7.640188', self.tester)
        self.assertEqual(obs, exp)

    def test_getitem_error(self):
        """Get item raises an error if key does not exists"""
        with self.assertRaises(KeyError):
            self.tester['Not_a_Sample']

    def test_setitem(self):
        """setitem raises an error (currently not allowed)"""
        with self.assertRaises(QiitaDBNotImplementedError):
            self.tester['SKM7.640188'] = Sample('SKM7.640188', self.tester)

    def test_delitem(self):
        """delitem raises an error (currently not allowed)"""
        with self.assertRaises(QiitaDBNotImplementedError):
            del self.tester['SKM7.640188']

    def test_iter(self):
        """iter returns an iterator over the sample ids"""
        obs = self.tester.__iter__()
开发者ID:teravest,项目名称:qiita,代码行数:70,代码来源:test_metadata_template.py


注:本文中的qiita_db.metadata_template.SampleTemplate._get_sample_ids方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。