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


Python FixturesManager.uninstall_fixture方法代码示例

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


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

示例1: TestSqlalchemyFixtures

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import uninstall_fixture [as 别名]
class TestSqlalchemyFixtures(testing.TestCase):

    def setUp(self):
        self.session = Session()
        self.manager = FixturesManager(db_session=self.session)
        self.manager.load("./charlatan/tests/data/relationships.yaml")

        Base.metadata.create_all(engine)

    def tearDown(self):
        Base.metadata.drop_all(engine)
        self.session.close()

    def test_double_install(self):
        """Verify that there's no double install."""
        self.manager.install_fixture("model")
        self.manager.install_fixture("color")

        self.assertEqual(self.session.query(Toaster).count(), 1)
        self.assertEqual(self.session.query(Color).count(), 1)

    def test_getting_from_database(self):
        """Verify that we can get from the database."""
        installed = Toaster(id=1)
        self.session.add(installed)
        self.session.commit()

        toaster = self.manager.install_fixture("from_database")
        self.assertEqual(toaster.id, 1)

    def test_installing_collection(self):
        """Verify that a collection of fixtures is in the database."""
        self.manager.install_fixture("model_list")

        self.assertEqual(self.session.query(Toaster).count(), 2)

    def test_inheritance_and_relationship(self):
        """Verify that inheritance works with relationships."""
        model, model_1 = self.manager.install_fixtures(('model', 'model_1'))

        self.assertTrue(isinstance(model.color, Color))
        self.assertTrue(isinstance(model_1.color, Color))

    def test_explicit_foreign_key(self):
        """Verify that we can get a db-computed foreign key explicitely."""
        model = self.manager.install_fixture('model_with_explicit_fk')
        assert model.color_id is not None

    def test_uninstall_deletes_fixtures(self):
        """Verify uninstalling a fixture drops it from the database."""
        self.manager.install_fixture("color")

        # sanity check
        self.assertEqual(self.session.query(Color).count(), 1)

        self.manager.uninstall_fixture("color")

        self.assertEqual(self.session.query(Color).count(), 0)
开发者ID:rtoussaint,项目名称:charlatan,代码行数:60,代码来源:test_sqlalchemy.py

示例2: test_uninstall_fixture

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import uninstall_fixture [as 别名]
    def test_uninstall_fixture(self):
        manager = FixturesManager()
        manager.load(
            './charlatan/tests/data/relationships_without_models.yaml')

        manager.install_fixture('simple_dict')
        manager.uninstall_fixture('simple_dict')

        # verify we are forgiving with list inputs
        manager.install_fixtures('simple_dict')
        manager.uninstall_fixtures('simple_dict')
开发者ID:rtoussaint,项目名称:charlatan,代码行数:13,代码来源:test_fixtures_manager.py

示例3: test_uninstall_non_installed_fixture

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import uninstall_fixture [as 别名]
    def test_uninstall_non_installed_fixture(self):
        """uninstall_fixture should return None.

        The method returns None since the fixture has not been previously
        installed.
        """

        fixtures_manager = FixturesManager()
        fixtures_manager.load(
            './charlatan/tests/data/relationships_without_models.yaml')

        fixture = fixtures_manager.uninstall_fixture('simple_dict')
        self.assertEqual(fixture, None)
开发者ID:joegilley,项目名称:charlatan,代码行数:15,代码来源:test_fixtures_manager.py

示例4: test_uninstall_fixture

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import uninstall_fixture [as 别名]
    def test_uninstall_fixture(self):
        """uninstall_fixture should return the fixture."""

        fixtures_manager = FixturesManager()
        fixtures_manager.load(
            './charlatan/tests/data/relationships_without_models.yaml')

        fixtures_manager.install_fixture('simple_dict')
        fixture = fixtures_manager.uninstall_fixture('simple_dict')
        self.assertEqual(fixture, {
            'field1': 'lolin',
            'field2': 2,
        })

        # verify we are forgiving with list inputs
        fixtures = fixtures_manager.install_fixtures('simple_dict')
        self.assertEqual(len(fixtures), 1)

        fixtures = fixtures_manager.uninstall_fixtures('simple_dict')
        self.assertEqual(len(fixtures), 1)
        self.assertEqual(fixtures[0], {
            'field1': 'lolin',
            'field2': 2,
        })
开发者ID:joegilley,项目名称:charlatan,代码行数:26,代码来源:test_fixtures_manager.py

示例5: test_uninstall_non_installed_fixture

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import uninstall_fixture [as 别名]
 def test_uninstall_non_installed_fixture(self):
     manager = FixturesManager()
     manager.load(
         './charlatan/tests/data/relationships_without_models.yaml')
     manager.uninstall_fixture('simple_dict')
开发者ID:rtoussaint,项目名称:charlatan,代码行数:7,代码来源:test_fixtures_manager.py


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