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


Python FixturesManager.load方法代码示例

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


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

示例1: TestRelationshipsWithoutModels

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
class TestRelationshipsWithoutModels(testing.TestCase,
                                     testcase.FixturesManagerMixin):

    def setUp(self):
        self.fixtures_manager = FixturesManager()
        self.fixtures_manager.load(
            './charlatan/tests/data/relationships_without_models.yaml')
        self.install_fixtures([
            'dict_with_nest', 'simple_dict', 'list_of_relationships'])
        self.init_fixtures()

    def test_dictionaries_nest(self):
        self.assertEqual(self.dict_with_nest['simple_dict'], self.simple_dict)

    def test_relationships_list(self):
        self.assertEqual([self.dict_with_nest, self.simple_dict],
                         self.list_of_relationships)

    def test_nested_list_of_relationships(self):
        nested_list_of_relationships = self.install_fixture(
            'nested_list_of_relationships')

        self.assertEqual(nested_list_of_relationships, {
            'dicts': [
                [self.dict_with_nest],
                [self.simple_dict],
            ]
        })

    def test_relationships_dict_attribute(self):
        parent = self.install_fixture('parent_dict.object1')
        child = self.install_fixture('child_dict.object1')

        self.assertEquals(child['field1'], parent['field1'])
开发者ID:fionaguoguolu,项目名称:charlatan,代码行数:36,代码来源:test_relationships_without_models.py

示例2: TestListOfFixtures

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

    def setUp(self):
        self.fm = FixturesManager()
        self.fm.load('./charlatan/tests/data/lists.yaml')

    def test_get_list_by_name(self):
        """Verify that lists of fixtures returns lists"""

        fixtures = self.fm.install_fixture('fixture_list')
        self.assertIsInstance(fixtures, list)

    def test_one_to_many_relationship(self):
        """Verify that relations to lists of fixtures work"""
        fixture = self.fm.install_fixture('related_fixture')
        self.assertEqual(
            fixture['elements'],
            self.fm.install_fixture('fixture_list')
        )

    def test_override(self):
        """Verify that we can override attributes on a list of fixtures."""
        fixtures = self.fm.install_fixture('fixture_list',
                                           overrides={"field1": 12})
        assert list(map(op.itemgetter('field1'), fixtures)) == [12, 12]
开发者ID:jvrsantacruz,项目名称:charlatan,代码行数:27,代码来源:test_lists_of_fixtures.py

示例3: TestSqlalchemyFixtures

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [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("relationship_alone")

        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)
开发者ID:joegilley,项目名称:charlatan,代码行数:37,代码来源:test_sqlalchemy.py

示例4: test_overrides_and_in_cache

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
def test_overrides_and_in_cache():
    manager = FixturesManager()
    manager.load('./docs/examples/simple_fixtures.yaml')
    # Add it to the cache
    manager.install_fixture("toaster")
    toaster = manager.install_fixture("toaster", overrides={"color": "blue"})
    assert toaster.color == 'blue'
开发者ID:rtoussaint,项目名称:charlatan,代码行数:9,代码来源:test_fixtures_manager.py

示例5: test_install_fixture_with_now

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
 def test_install_fixture_with_now(self):
     """Verify that we can install a fixture with !now tag."""
     manager = FixturesManager()
     manager.load('./charlatan/tests/data/simple.yaml')
     fixture = manager.install_fixture('fixture')
     self.assertEqual(fixture,
                      {'now': datetime(2014, 12, 30, 11, 0,
                                       tzinfo=pytz.utc)})
开发者ID:rtoussaint,项目名称:charlatan,代码行数:10,代码来源:test_fixtures_manager.py

示例6: test_load_two_files

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
 def test_load_two_files(self):
     """Verify we can load two files."""
     manager = FixturesManager()
     manager.load(
         './charlatan/tests/data/relationships_without_models.yaml')
     manager.load(
         './charlatan/tests/data/simple.yaml')
     assert 'simple_dict' in manager.keys()
开发者ID:rtoussaint,项目名称:charlatan,代码行数:10,代码来源:test_fixtures_manager.py

示例7: get_collection

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
def get_collection(collection):
    """Return FixtureCollection.

    :param str collection: name of collection to import
    """
    manager = FixturesManager()
    manager.load("docs/examples/collection.yaml")
    return manager.collection.get(collection)
开发者ID:fionaguoguolu,项目名称:charlatan,代码行数:10,代码来源:test_fixture_collection.py

示例8: TestSqlalchemyFixtures

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [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

示例9: test_dependency_parsing

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
 def test_dependency_parsing(self):
     fm = FixturesManager()
     fm.load(
         './charlatan/tests/data/dependencies.yaml'
     )
     assert fm.depgraph.has_edge_between('fixture1', 'fixture2')
     assert fm.depgraph.has_edge_between('fixture1', 'fixture3')
     assert fm.depgraph.has_edge_between('fixture4', 'fixture3')
     assert fm.depgraph.has_edge_between('fixture2', 'fixture4')
开发者ID:joegilley,项目名称:charlatan,代码行数:11,代码来源:test_fixtures_manager.py

示例10: test_constructs_ancestors

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
 def test_constructs_ancestors(self):
     fm = FixturesManager()
     fm.load(
         './charlatan/tests/data/dependencies.yaml'
     )
     assert not fm.cache
     # loading fixture3 should load fixture1 and fixture2 also
     fm.get_fixture('fixture3')
     self.assertIn('fixture1', fm.cache)
     self.assertIn('fixture4', fm.cache)
开发者ID:joegilley,项目名称:charlatan,代码行数:12,代码来源:test_fixtures_manager.py

示例11: test_uninstall_fixture

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [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

示例12: test_install_fixture

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
    def test_install_fixture(self):
        """install_fixture should return the fixture."""
        manager = FixturesManager()
        manager.load(
            './charlatan/tests/data/relationships_without_models.yaml')

        fixture = manager.install_fixture('simple_dict')

        self.assertEqual(fixture, {
            'field1': 'lolin',
            'field2': 2,
        })
开发者ID:rtoussaint,项目名称:charlatan,代码行数:14,代码来源:test_fixtures_manager.py

示例13: test_uninstall_non_installed_fixture

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [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

示例14: TestRelationshipsWithoutModels

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
class TestRelationshipsWithoutModels(testing.TestCase,
                                     testcase.FixturesManagerMixin):

    fixtures = ('dict_with_nest', 'simple_dict', 'list_of_relationships',)

    def setUp(self):
        self.fixtures_manager = FixturesManager()
        self.fixtures_manager.load(
            './charlatan/tests/data/relationships_without_models.yaml')
        self.init_fixtures()

    def test_dictionaries_nest(self):
        self.assertEqual(self.dict_with_nest['simple_dict'], self.simple_dict)

    def test_relationships_list(self):
        self.assertEqual([self.dict_with_nest, self.simple_dict],
                         self.list_of_relationships)
开发者ID:joegilley,项目名称:charlatan,代码行数:19,代码来源:test_relationships_without_models.py

示例15: test_uninstall_fixtures

# 需要导入模块: from charlatan import FixturesManager [as 别名]
# 或者: from charlatan.FixturesManager import load [as 别名]
    def test_uninstall_fixtures(self):
        """uninstall_fixtures should return the list of installed fixtures."""
        fixtures_manager = FixturesManager()
        fixtures_manager.load(
            './charlatan/tests/data/relationships_without_models.yaml')

        fixture_keys = ('simple_dict', 'dict_with_nest')

        fixtures_manager.install_fixtures(fixture_keys)
        self.assertEqual(len(fixtures_manager.cache.keys()), 2)

        fixtures = fixtures_manager.uninstall_fixtures(fixture_keys)
        self.assertEqual(len(fixtures), 2)
        self.assertEqual(len(fixtures_manager.cache.keys()), 0)

        # uninstalling non-exiting fixtures should not raise an exception
        fixtures = fixtures_manager.uninstall_fixtures(fixture_keys)
        self.assertEqual(len(fixtures), 0)
        self.assertEqual(len(fixtures_manager.cache.keys()), 0)
开发者ID:joegilley,项目名称:charlatan,代码行数:21,代码来源:test_fixtures_manager.py


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