factory-boy Questions
5
Solved
I am considering using the factory_boy library for API testing. An example from the documentation is:
class UserFactory(factory.Factory):
class Meta:
model = base.User
first_name = "John"
las...
Eventually asked 2/6, 2015 at 14:51
1
note: I will try to explain the use case with a simplified scenario (which might look really odd to you).
I am having 2 models (which are related but do not have a foreign key):
# models.py
class...
Runin asked 5/2, 2019 at 8:24
2
Solved
simple model(models.py):
from django.db import models
class MyModel(models.Model):
start_date = models.DateField()
simple factory(test_factories.py):
from datetime import date
import factory
...
Headley asked 16/8, 2017 at 16:22
1
Solved
I have two Django models (Customer and CustomerAddress) that both contain ForeignKeys to each other. I am using factory-boy to manage creation of these models, and cannot save a child factory insta...
Sutlej asked 11/4, 2020 at 23:41
1
When using factory_boy in Django, how can I achieve this?
models.py
class TestModel(models.Model):
name = CharField()
order = IntegerField()
recipes.py
class TestModelFactory(factory.django....
Decentralize asked 30/8, 2018 at 14:54
1
Solved
I'm a new to factory_boy module. In my code, I import factory and then used this import to access the fuzzy attribute with factory.fuzzy then it throws error module 'factory' has no attribute 'fuzz...
Wiggle asked 29/3, 2020 at 12:35
3
Solved
I am trying to use factory boy to generate fake entries but I'm stepping on an issue related with the boolean field.
Follows the Model and ModelFactory:
# models.py
class Record(models.Model):
...
Pauiie asked 8/12, 2019 at 20:50
1
Solved
I'm writing unit tests in a Django project. I've got a factory to create objects using the .create() method. So in my unit tests I'm using this:
device = DeviceFactory.create()
This always creat...
Cornela asked 4/11, 2019 at 15:54
2
Solved
I have a many-to-one relationship in my SQLAlchemy models. One report has many samples (simplified for brevity):
class Sample(db.Model, CRUDMixin):
sample_id = Column(Integer, primary_key=True)
...
Chiton asked 15/8, 2019 at 6:47
7
Solved
When I am writing unit tests in dynamically-typed Ruby or Python, I use the libraries factory_girl and factory_boy, respectively, in order to conveniently generate objects under test. They provide ...
Descartes asked 18/2, 2015 at 4:59
2
Solved
I have a Django Model defined like below:
class CustomModel(models.Model):
column = models.CharField(max_length=50, unique=True)
Define a Factory for the model
from factory_boy import Django...
Vierno asked 10/12, 2017 at 7:13
1
Solved
I am learning django test and i found django factory boy library very helpfull for writing testcase but one thing i am not getting..
forexample my one of Factory name is BlogFactory
so i notice, ...
Swordbill asked 22/6, 2019 at 16:9
1
Solved
I am writing tests for a large Django application, as part of this process I am gradually creating factories for all models of the different apps within the Django project.
However, I've run into ...
Southwestward asked 18/4, 2019 at 14:36
1
Solved
I am writing tests for a large Django application with multiple apps. As part of this process I am gradually creating factories for all models of the different apps within the Django project.
How...
Cookson asked 12/4, 2019 at 8:48
2
I'm running into the classic DateTimeField received a naive datetime while time zone support is active warning with a twist. The error occurs when I run tests that utilize factories provided by fac...
Noticeable asked 11/12, 2013 at 4:40
1
Solved
import factory.fuzzy
import faker
from core.strings import underscore_15
from factory import DjangoModelFactory, SubFactory
faker = faker.Factory.create()
class SubProjectFactory(DjangoModelFact...
Chum asked 10/12, 2018 at 23:40
1
Is it possible to use Traits (or anything else in Factory Boy) to trigger the creation of other factory objects? For example: In a User-Purchase-Product situation, I want to create a user and infor...
Chemosphere asked 21/11, 2017 at 17:27
3
In defining a ModelFactory in FactoryBoy, I need to access an attribute of another model created by SubFactory and assign it to this ModelFactory's attribute.
This is what I want to do:
import fa...
Pod asked 31/7, 2013 at 18:55
3
Solved
Let's say you have these Django models related this way:
class Service:
restaurant = models.ForeignKey(Restaurant)
hist_day_period = models.ForeignKey(DayPeriod)
class DayPeriod:
restaurant = ...
Doomsday asked 24/11, 2017 at 13:49
3
I want to find a way to properly test my code with Factory Boy.
There are a model, like this:
from django.db import models
class MyModel(models.Model):
param1 = <some field>
param1 = <...
Declivitous asked 19/10, 2012 at 9:9
1
I'm trying to set up data for a test case that requires an django.db.models.ImageField. I'm trying to use factory.django.ImageField from factory-boy, but get the error AttributeError: 'ImageField' ...
Excellent asked 4/8, 2015 at 12:16
1
Solved
I am working on a factory for a model and I am trying fill a field that has a list of choices. When I attempt to create an object with the Factory where I attempt to fill in a random choice from th...
Briny asked 19/3, 2018 at 20:16
2
I am using django 1.6 and factory-boy.
class UserFactory(factory.Factory):
class Meta:
model = models.User
username = factory.Sequence(lambda n: 'user%d' % n)
Here username is a simple Char...
Samella asked 9/11, 2016 at 12:35
2
Solved
FactoryBoy seem to always create the instances in the default database. But I have the following problem.
cpses = CanonPerson.objects.filter(persons__vpd=6,
persons__country="United States").usin...
Pragmatism asked 24/10, 2014 at 14:41
1
Solved
I'm trying to populate my Django project with some random data using factory_boy and faker. However, when I try to create an instance of my UserFactory object I'm getting the error TypeError: () mi...
Jamajamaal asked 5/12, 2017 at 22:40
© 2022 - 2024 — McMap. All rights reserved.