fixtures

pytest fixtures in a separate directory

做~自己de王妃 提交于 2019-11-30 20:57:24
I'm looking to create a pytest structure where I can separate the fixtures from the tests completely. The reason for this separation is that I want to include the fixtures directory as an external item in subversion and share it between multiple projects. tree of desired structure project | conftest.py | +---fixtures | __init__.py | conftest.py | fixture_cifs.py | fixture_ftp.py | fixture_service.py | \---tests | test_sometest1.py | test_sometest2.py | \---configurations sometest1.conf sometest2.conf I want to implement the functionality for each fixture in a separate file in order to avoid a

Django fixtures for permissions

懵懂的女人 提交于 2019-11-30 18:50:29
I'm creating fixtures for permissions in Django. I'm able to get them loaded the way it's needed. However, my question is..say I want to load a fixture for the table auth_group_permissions , I need to specify a group_id and a permission_id , unfortunately fixtures aren't the best way to handle this. Is there an easier way to do this programmatically? So that I can get the id for particular values and have them filled in? How is this normally done? Filip Dupanović The proper solution is to create the permissions in the same manner the framework itself does. You should connect to the built-in

Convert fixtures into Factory Girl in Rails

浪尽此生 提交于 2019-11-30 17:53:14
问题 I'd like to migrate my fixtures to "Factory Girl" in Rails. Is there any easy way to convert all yml files in a factories.rb file? 回答1: I am assuming what you are looking to do is find a script which will look through your models and generate the factories for them. I tried this once (with something other than factory_girl) and found it full of bad data. I would suggest that you slowly transition to using factories. As you write new tests or update old ones, create the necessary factories. As

Automatic associations in ruby on rails fixtures

和自甴很熟 提交于 2019-11-30 17:16:14
As described in this article , I am using automatic associations in fixtures. For example, if a region object has a country id, instead of doing "country_id": 1, I do "country": "USA". "USA" is a label in my countries.yml file, so fixtures knows how to take care of this. However, this only works when you do not specify an ID value for the countries object. So I cannot assign USA's ID to be 1. But if I do not assign it to be 1, it ends up being some large value 8974343...which is kinda strange. Is there a way to get fixtures to auto-generate id's that are not super high? ....or is this ok?

Setting up parameter as array in Nelmio Alice fixture generator

…衆ロ難τιáo~ 提交于 2019-11-30 15:12:57
问题 I'm asking if it's possible to pass an array as value for some elements? For example in my case I'm trying to set roles for a FOSUserBundle User entity that takes roles as an array of values and not plain values. I have this in my fixture: UserBundle\Entity\User: User0: username: admin email: admin@local.com enabled: 1 plainPassword: admin roles: [ROLE_ADMIN] groups: @Group0 User{1..10}: username: <firstNameMale> email: <companyEmail> enabled: <boolean(35)> plainPassword: <lexify> roles: 35%?

Setting up parameter as array in Nelmio Alice fixture generator

ε祈祈猫儿з 提交于 2019-11-30 13:59:02
I'm asking if it's possible to pass an array as value for some elements? For example in my case I'm trying to set roles for a FOSUserBundle User entity that takes roles as an array of values and not plain values. I have this in my fixture: UserBundle\Entity\User: User0: username: admin email: admin@local.com enabled: 1 plainPassword: admin roles: [ROLE_ADMIN] groups: @Group0 User{1..10}: username: <firstNameMale> email: <companyEmail> enabled: <boolean(35)> plainPassword: <lexify> roles: 35%? [ROLE_ADMIN, ROLE_USER, ROLE_PROFILE_ONE, ROLE_PROFILE_TWO] groups: @Group* But it's not working and I

Loading fixtures in django unit tests

久未见 提交于 2019-11-30 10:45:52
I'm trying to start writing unit tests for django and I'm having some questions about fixtures: I made a fixture of my whole project db (not certain application) and I want to load it for each test, because it looks like loading only the fixture for certain app won't be enough. I'd like to have the fixture stored in /proj_folder/fixtures/proj_fixture.json. I've set the FIXTURE_DIRS = ('/fixtures/',) in my settings.py. Then in my testcase I'm trying fixtures = ['proj_fixture.json'] but my fixtures don't load. How can this be solved? How to add the place for searching fixtures? In general, is it

Symfony2 execute SQL file in Doctrine Fixtures Load

给你一囗甜甜゛ 提交于 2019-11-30 08:24:16
I'm migrating an old web app based on SQL Server and ASP to Symfony2 and MySQL. I made some queries and export old data to individual SQL files. How can I execute thoses files in my fixtures, when I run the command $php app/console doctrine:fixtures:load Now I have some fixtures that works directly with Doctrine ORM and entities, but I have a lot of data to import. Pablo I find a good solution. I didn't find an exec method in class ObjectManager , so... this work very well for me. public function load(ObjectManager $manager) { // Bundle to manage file and directories $finder = new Finder();

pytest fixtures in a separate directory

纵饮孤独 提交于 2019-11-30 04:39:59
问题 I'm looking to create a pytest structure where I can separate the fixtures from the tests completely. The reason for this separation is that I want to include the fixtures directory as an external item in subversion and share it between multiple projects. tree of desired structure project | conftest.py | +---fixtures | __init__.py | conftest.py | fixture_cifs.py | fixture_ftp.py | fixture_service.py | \---tests | test_sometest1.py | test_sometest2.py | \---configurations sometest1.conf

How and where does py.test find fixtures

谁说我不能喝 提交于 2019-11-30 04:15:53
Where and how does py.test look for fixtures? I have the same code in 2 files in the same folder. When I delete conftest.py, cmdopt cannot be found running test_conf.py (also in same folder. Why is sonoftest.py not searched? # content of test_sample.py def test_answer(cmdopt): if cmdopt == "type1": print ("first") elif cmdopt == "type2": print ("second") assert 0 # to see what was printed content of conftest.py import pytest def pytest_addoption(parser): parser.addoption("--cmdopt", action="store", default="type1", help="my option: type1 or type2") @pytest.fixture def cmdopt(request): return