fixtures

Django fixtures for permissions

◇◆丶佛笑我妖孽 提交于 2020-01-11 01:09:03
问题 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? 回答1: The proper solution is to create the

Getting fixtures to load after creating a join table entity

别说谁变了你拦得住时间么 提交于 2020-01-06 08:45:09
问题 I recently asked the following question: Many to Many, One to Many or Many to One After doing the updates suggested by @inanzzz my database looks great now however my fixtures seem to not work. I get the following error when trying to load them: [Symfony\Component\Debug\Exception\ContextErrorException] Catchable Fatal Error: Argument 1 passed to BBQ\Charcoal\WebsiteBundle\Enti ty\Templates::addModule() must be an instance of BBQ\Charcoal\WebsiteBundle \Entity\TemplateModules, instance of

Parametrizing tests depending of also parametrized values in pytest

徘徊边缘 提交于 2020-01-06 07:21:49
问题 I have a test where I have a setup method, that should receive a dataset , and a test function, that should run for each data in dataset Basically I would need something like: datasetA = [data1_a, data2_a, data3_a] datasetB = [data1_b, data2_b, data3_b] @pytest.fixture(autouse=True, scope="module", params=[datasetA, datasetB]) def setup(dataset): #do setup yield #finalize #dataset should be the same instantiated for the setup @pytest.mark.parametrize('data', [data for data in dataset]) def

Fixtures with polymorphic association not working

孤者浪人 提交于 2020-01-06 06:45:22
问题 I'm trying to implement the Rolify gem but have trouble adding fixtures with a scope for it. The last line of the (model) test below fails because currently the moderator role seems to be given to @user globally instead of only for organization one. The fixtures below aren't using resource_id and resource_type , which are mentioned in the gem documentation for fixtures, but I'm not sure how to use them. How should I set the scope for the moderator role to only organization one? roles.yml

Regenerate fixture test files in Rails

99封情书 提交于 2020-01-03 17:48:11
问题 How do I regenerate all the YML fixture files? I accidentally deleted them. 回答1: @brian, I'm using the following script to generate the fixtures from a given sql This is under my lib/task directory as a rake task namespace :fixture_generator do desc "generate fixtures for a given sql query from the current development database" task :fixture_generator, [:sql, :file_name] => :environment do |t, args| args.with_defaults(:sql => nil, :file_name => nil) i = "000" p "creating fixture - #{args.file

Multiple Fixture Sets in Rails?

自闭症网瘾萝莉.ら 提交于 2020-01-03 08:37:10
问题 Is there a way to have different fixture sets (what you might call a "fixture profile") for Rails tests? The best I've found is a Rails 1.3 plugin from 2006. I thought there'd be more demand for this kind of thing. In my case, I want an "offline" profile which would include a cache of all data, and another "online" profile which would be required to fetch data. 回答1: Since no-one's answered, I'll say that the best solution here seems to be Factory Girl. It's not built-in Rails fixtures, but it

Rails Fixtures with BCrypt

血红的双手。 提交于 2020-01-03 08:07:09
问题 I'm having a problem with fixtures for BCrypt password: my User model is both setup with has_secure_password and validates_presence_of :password . The point is that BCrypt uses password and password_confirmation but in the schema there is only the password_digest field. The fixture is complaining that the password field does not exists. How can I avoid this? Thank you 回答1: Seems that fixtures are being pushed to the database directly. That means that instead of password: you need password

Rails - Testing fixtures error NoMethodError: undefined method `type' for nil:NilClass

谁说我不能喝 提交于 2020-01-03 07:27:28
问题 I have a problem running tests that use fixtures with associations between models. Here's the error I get, as soon as I run rake test : ERROR["test_truth", SevenPortfolioTest, 0.005154775] test_truth#SevenPortfolioTest (0.01s) NoMethodError: NoMethodError: undefined method `type' for nil:NilClass ERROR["test_should_destroy_item_video", SevenPortfolio::ItemVideosControllerTest, 0.008887804] test_should_destroy_item_video#SevenPortfolio::ItemVideosControllerTest (0.01s) NoMethodError:

How to use multiple pytest conftest files in one test run with a duplicated parser.addoption?

佐手、 提交于 2020-01-03 01:41:32
问题 I have a pytest testing project running selenium tests that has a structure like: ProjRoot | |_Pytest.ini |_____________TestFolderA | | | |_test_folderA_tests1.py | |_test_folderA_tests2.py | |____________TestFolderB | | | |_test_folderB_test1.py | |_test_folderA_tests2.py | | |___________TestHelperModules | | | |_VariousTestHelperModules | |____________DriversAndTools |___(contains chromedriver.exe, firefox profile folder etc) I have a confTest.py file which I currently run in the ProjRoot,

Why cant unittest.TestCases see my py.test fixtures?

心已入冬 提交于 2020-01-02 02:21:27
问题 I'm trying to use py.test 's fixtures with my unit tests, in conjunction with unittest . I've put several fixtures in a conftest.py file at the top level of the project (as described here), decorated them with @pytest.fixture , and put their names as arguments to the test functions that require them. The fixtures are registering correctly, as shown by py.test --fixtures test_stuff.py , but when I run py.test , I get NameError: global name 'my_fixture' is not defined . This appears to only