本文整理汇总了Python中model_mommy.mommy.make函数的典型用法代码示例。如果您正苦于以下问题:Python make函数的具体用法?Python make怎么用?Python make使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_siguiente_movimiento
def test_siguiente_movimiento(self):
tipo_movimiento = mommy.make(TipoMovimiento, codigo= '', incrementa = True)
mov1 = mommy.make(Movimiento, id_movimiento = '', fecha_operacion = datetime.now(), tipo_movimiento = tipo_movimiento)
mov2 = mommy.make(Movimiento, id_movimiento = '', fecha_operacion = datetime.now(), tipo_movimiento = tipo_movimiento)
mov3 = mommy.make(Movimiento, id_movimiento = '', fecha_operacion = datetime.now(), tipo_movimiento = tipo_movimiento)
self.assertEqual(mov2.pk, mov1.siguiente())
self.assertEqual(mov3.pk, mov2.siguiente())
开发者ID:joseamaya,项目名称:tambox,代码行数:7,代码来源:tests.py
示例2: test_h1
def test_h1(self):
testuser = mommy.make(settings.AUTH_USER_MODEL)
mommy.make('core.Candidate', relatedstudent__user=testuser)
mockresponse = self.mock_http200_getrequest_htmls(requestuser=testuser)
self.assertEqual(
'Student dashboard',
mockresponse.selector.one('h1').alltext_normalized)
开发者ID:Nasmi1,项目名称:devilry-django,代码行数:7,代码来源:test_dashboard.py
示例3: setUp
def setUp(self):
self.admin_user = User.objects.create_superuser(
'[email protected]', 'example')
self.future_date = timezone.now().date() + timedelta(days=10)
self.job_open = mommy.make(
Job,
review_status=Job.OPEN,
)
self.job_under_review = mommy.make(
Job,
review_status=Job.UNDER_REVIEW,
reviewer=self.admin_user,
)
self.job_ready_to_publish = mommy.make(
Job,
review_status=Job.READY_TO_PUBLISH,
reviewer=self.admin_user,
)
self.job_published = mommy.make(
Job,
review_status=Job.PUBLISHED,
reviewer=self.admin_user,
published_date=timezone.now(),
expiration_date=self.future_date,
)
self.job_rejected = mommy.make(
Job,
review_status=Job.REJECTED,
reviewer=self.admin_user,
)
self.client.login(username=self.admin_user.email, password='example')
开发者ID:JulianVolodia,项目名称:djangogirls,代码行数:31,代码来源:test_admin.py
示例4: setUpTestData
def setUpTestData(cls):
cls.semester = mommy.make(Semester)
cls.course = mommy.make(Course, pk=7, state="published", semester=cls.semester)
users = mommy.make(UserProfile, _quantity=3)
cls.course.participants = users
cls.course.voters = users[:2]
开发者ID:Steditor,项目名称:EvaP,代码行数:7,代码来源:test_models.py
示例5: test_results_are_filtered_based_on_queryset
def test_results_are_filtered_based_on_queryset(self):
class Car(models.Model):
name = models.CharField(max_length=255)
class CarIndex(Index):
class Meta:
fields = ['name']
model = Car
with connection.schema_editor() as editor:
editor.create_model(Car)
# the signal handler will automatically add these to ES for us
car = make(Car, name="hi", pk=1)
car2 = make(Car, name="hi 2", pk=2)
car3 = make(Car, name="hi 3", pk=3)
class Form(SearchForm):
def get_queryset(self):
# we purposely exclude one of the options, so we can test that
# it isn't in the search results
return super().get_queryset().exclude(pk=1)
form = Form({"q": "hi"}, index=CarIndex)
# the count should be 2 (not 3), since the queryset excluded Car.pk=1
self.assertEqual(form.search().count(), 2)
results = form.results(page=1)
self.assertEqual(set(results), set([car2, car3]))
class Form(BaseSearchForm):
pass
form = Form({"q": "hi"}, index=CarIndex)
self.assertEqual(set(form.results()), set([car, car2, car3]))
开发者ID:PSU-OIT-ARC,项目名称:elasticmodels,代码行数:35,代码来源:tests.py
示例6: setUp
def setUp(self):
self.old_dade_fips = '12025'
self.new_dade_fips = '12086'
mommy.make(
CountyMortgageData,
current=100,
date=datetime.date(2008, 1, 1),
fips=self.old_dade_fips,
ninety=100,
other=100,
sixty=100,
thirty=100,
total=500)
mommy.make(
CountyMortgageData,
current=100,
date=datetime.date(2008, 1, 1),
fips=self.new_dade_fips,
ninety=100,
other=100,
sixty=100,
thirty=100,
total=500)
开发者ID:chosak,项目名称:cfgov-refresh,代码行数:26,代码来源:test_scripts.py
示例7: test_only_admin_or_coordinator_can_edit_course
def test_only_admin_or_coordinator_can_edit_course(client, admin_client):
course = Course.objects.create(slug='dbsql', name='A course', abstract='asdf')
professor = create_user('professor')
client.login(username=professor.username, password='password')
response = client.post('/api/course/{}'.format(str(course.id)),
{'id': course.id,
'slug': course.slug,
'abstract': 'A abstract'},
content_type='application/json;charset=UTF-8')
assert response.status_code == 403
assert course.abstract == 'asdf'
mommy.make('CourseProfessor', user=professor, course=course, role='coordinator')
response = client.post('/api/course/{}'.format(str(course.id)), {'id': str(course.id),
'slug': course.slug,
'abstract': 'A abstract'})
changed_course = Course.objects.get(id=course.id)
assert response.status_code == 200
assert changed_course.abstract == 'A abstract'
response = admin_client.post('/api/course/{}'.format(str(course.id)), {'id': str(course.id),
'slug': course.slug,
'abstract': 'Another abstract'})
changed_course = Course.objects.get(id=course.id)
assert response.status_code == 200
assert changed_course.abstract == 'Another abstract'
开发者ID:hacklabr,项目名称:timtec,代码行数:30,代码来源:test_views.py
示例8: test_post_comment_private_history_visibility
def test_post_comment_private_history_visibility(self):
testgroup = mommy.make('core.AssignmentGroup', parentnode__parentnode=self.__make_active_period())
testuser = mommy.make(settings.AUTH_USER_MODEL)
self.__make_examiner_for_user(user=testuser, group=testgroup)
testfeedbackset = group_mommy.feedbackset_first_attempt_unpublished(group=testgroup)
groupcomment = mommy.make('devilry_group.GroupComment',
user=testuser,
user_role='examiner',
text='unedited',
part_of_grading=True,
visibility=group_models.GroupComment.VISIBILITY_PRIVATE,
feedback_set=testfeedbackset)
messagesmock = mock.MagicMock()
self.mock_http302_postrequest(
cradmin_role=testgroup,
requestuser=testuser,
viewkwargs={'pk': groupcomment.id},
requestkwargs={
'data': {
'text': 'edited'
}
},
messagesmock=messagesmock)
edit_history_entry = group_models.GroupCommentEditHistory.objects.get()
self.assertEqual(edit_history_entry.visibility, group_models.GroupComment.VISIBILITY_PRIVATE)
开发者ID:devilry,项目名称:devilry-django,代码行数:25,代码来源:test_feedbackfeed_examiner_edit_comment.py
示例9: test_publish_latest_offer_publishes_oldest_offer
def test_publish_latest_offer_publishes_oldest_offer(self):
"""
Test that publish_latest_offer publishes the oldest offer
"""
self.offer.delete()
offers = mommy.make(
Offer,
_quantity=3,
is_ready=True,
is_request=True,
status=Offer.UNPUBLISHED,
provider=self.provider,
creator=self.user
)
# Create some offers who should not be affected since they are invalid
mommy.make(Offer, is_ready=False, is_request=True)
mommy.make(Offer, status=Offer.PUBLISHED)
# Set the oldest to newest
offers[0].readied_at -= timedelta(days=3)
offers[1].readied_at -= timedelta(days=2)
offers[2].readied_at -= timedelta(days=1)
self.assertTrue(publish_latest_offer.delay().successful())
new_offer = Offer.objects.get(pk=offers[0].pk)
self.assertEqual(new_offer.status, Offer.PUBLISHED)
self.assertFalse(new_offer.is_request)
self.assertEqual(Offer.objects.filter(status=Offer.PUBLISHED, is_request=False).count(), 2)
开发者ID:BlaZeX,项目名称:OfferListing,代码行数:32,代码来源:test_tasks.py
示例10: test_get_courses_user_has_role
def test_get_courses_user_has_role(client):
course = mommy.make('Course', slug='dbsql', name='A course')
another_course = mommy.make('Course', slug='mysql', name='Another course')
course_whose_professor_coordinate = mommy.make('Course', slug='coordinatedcourse',
name='Course whose professor coordinate')
another_course_whose_professor_coordinate = mommy.make('Course', slug='anothercoordinatedcourse',
name='Another course whose professor coordinate')
professor1 = assign_professor_to_course(course, new_professor_username='professor1', role='assistant')
assign_professor_to_course(another_course, existing_professor=professor1, role='assistant')
assign_professor_to_course(course_whose_professor_coordinate, existing_professor=professor1, role='coordinator')
assign_professor_to_course(another_course_whose_professor_coordinate, existing_professor=professor1,
role='coordinator')
client.login(username=professor1.username, password='password')
response = client.get('/my-courses/')
assert response.status_code == 200
courses_user_assist = response.context[-1]['courses_user_assist']
assert courses_user_assist
courses_user_coordinate = response.context[-1]['courses_user_coordinate']
assert courses_user_coordinate
开发者ID:hacklabr,项目名称:timtec,代码行数:33,代码来源:test_views.py
示例11: setUp
def setUp(self):
self.provider = mommy.make(Provider)
self.offer = mommy.make(Offer, provider=self.provider, status=Offer.PUBLISHED)
self.user = User.objects.create_user('user', '[email protected]', 'pass')
self.user.user_profile.provider = self.provider
self.user.user_profile.save()
开发者ID:BlaZeX,项目名称:OfferListing,代码行数:7,代码来源:test_tasks.py
示例12: setUp
def setUp(self):
self.fecha_actual = date.today()
self.fecha_proxima = date(2017,1,1)
self.pe1 = mommy.make(Pedido,codigo = '',fecha = self.fecha_actual)
self.pe2 = mommy.make(Pedido,codigo = '',fecha = self.fecha_actual)
self.pe3 = mommy.make(Pedido,codigo = '',fecha = self.fecha_actual)
self.pe4 = mommy.make(Pedido,codigo = '',fecha = self.fecha_proxima)
开发者ID:joseamaya,项目名称:tambox,代码行数:7,代码来源:tests.py
示例13: test_anterior_movimiento
def test_anterior_movimiento(self):
tipo_movimiento = mommy.make(TipoMovimiento, codigo= '', incrementa = False)
mov1 = mommy.make(Movimiento, id_movimiento = '', fecha_operacion = datetime.now(), tipo_movimiento = tipo_movimiento)
mov2 = mommy.make(Movimiento, id_movimiento = '', fecha_operacion = datetime.now(), tipo_movimiento = tipo_movimiento)
mov3 = mommy.make(Movimiento, id_movimiento = '', fecha_operacion = datetime.now(), tipo_movimiento = tipo_movimiento)
self.assertEqual(mov1.pk, mov2.anterior())
self.assertEqual(mov2.pk, mov3.anterior())
开发者ID:joseamaya,项目名称:tambox,代码行数:7,代码来源:tests.py
示例14: test_get_gender_with_registration
def test_get_gender_with_registration(self):
""" Pull from registration, if available """
reg = mommy.make(Registration, trips_year=self.trips_year, gender='FEMALE')
incoming = mommy.make(
IncomingStudent, trips_year=self.trips_year, gender='MALE', registration=reg
)
self.assertEqual(incoming.get_gender(), 'female')
开发者ID:rlmv,项目名称:doc-trips,代码行数:7,代码来源:tests.py
示例15: test_post_initial_empty_comment_can_be_edited
def test_post_initial_empty_comment_can_be_edited(self):
testgroup = mommy.make('core.AssignmentGroup', parentnode__parentnode=self.__make_active_period())
testuser = mommy.make(settings.AUTH_USER_MODEL)
self.__make_examiner_for_user(user=testuser, group=testgroup)
testfeedbackset = group_mommy.feedbackset_first_attempt_unpublished(group=testgroup)
groupcomment = mommy.make('devilry_group.GroupComment',
user=testuser,
user_role='examiner',
feedback_set=testfeedbackset)
messagesmock = mock.MagicMock()
self.mock_http302_postrequest(
cradmin_role=testgroup,
requestuser=testuser,
viewkwargs={'pk': groupcomment.id},
requestkwargs={
'data': {
'text': 'edited'
}
},
messagesmock=messagesmock)
db_comment = group_models.GroupComment.objects.get(id=groupcomment.id)
edit_history = group_models.GroupCommentEditHistory.objects.get()
self.assertEqual(group_models.GroupCommentEditHistory.objects.count(), 1)
self.assertEqual('edited', db_comment.text)
self.assertEqual('', edit_history.pre_edit_text)
self.assertEqual('edited', edit_history.post_edit_text)
messagesmock.add.assert_called_once_with(messages.SUCCESS, 'Comment updated!', '')
开发者ID:devilry,项目名称:devilry-django,代码行数:27,代码来源:test_feedbackfeed_examiner_edit_comment.py
示例16: test_section_and_triptype_preferences
def test_section_and_triptype_preferences(self):
reg = mommy.make(Registration, trips_year=self.trips_year)
triptype = mommy.make(TripType, pk=1, trips_year=self.trips_year)
section = mommy.make(
Section,
pk=1,
trips_year=self.trips_year,
leaders_arrive=date(2015, 1, 1),
name='A',
)
data = {'triptype_1': 'FIRST CHOICE', 'section_1': 'PREFER'}
data.update(self.REGISTRATION_DATA)
form = RegistrationForm(trips_year=self.trips_year, instance=reg, data=data)
reg = form.save()
self.assertEqual(form.fields['section_1'].label, 'A — Jan 02 to Jan 06')
tts = reg.registrationtriptypechoice_set.all()
self.assertEqual(len(tts), 1)
self.assertEqual(tts[0].triptype, triptype)
self.assertEqual(tts[0].preference, 'FIRST CHOICE')
secs = reg.registrationsectionchoice_set.all()
self.assertEqual(len(secs), 1)
self.assertEqual(secs[0].section, section)
self.assertEqual(secs[0].preference, 'PREFER')
开发者ID:rlmv,项目名称:doc-trips,代码行数:26,代码来源:tests.py
示例17: setUp
def setUp(self):
self.division = mommy.make(JobCategory)
self.region = mommy.make(JobRegion)
page_clean = patch('jobmanager.models.pages.CFGOVPage.clean')
page_clean.start()
self.addCleanup(page_clean.stop)
开发者ID:OrlandoSoto,项目名称:cfgov-refresh,代码行数:7,代码来源:test_pages.py
示例18: test_get_city_id_case_insensitive_twice
def test_get_city_id_case_insensitive_twice(self):
city = mommy.make(models.City, name="abcd", parent=self.parent)
city2 = mommy.make(models.City, name="ABCD", parent=self.parent)
city_in_other_country = mommy.make(models.City, name="abcd", parent=self.foreign_country)
response = self.client.get(reverse('crm_get_city_id')+"?name="+"ABCD"+"&country=0")
self.assertEqual(200, response.status_code)
self.assertContains(response, "ABCD")
开发者ID:Maxence42,项目名称:balafon,代码行数:7,代码来源:test_cities.py
示例19: test_private_course
def test_private_course(self):
student = UserProfile.objects.get(username="student")
contributor = UserProfile.objects.get(username="contributor")
responsible = UserProfile.objects.get(username="responsible")
test1 = mommy.make(UserProfile, username="test1")
test2 = mommy.make(UserProfile, username="test2")
mommy.make(UserProfile, username="random")
degree = mommy.make(Degree)
private_course = mommy.make(Course, state='published', is_private=True, semester=self.semester, participants=[student, test1, test2], voters=[test1, test2], degrees=[degree])
mommy.make(Contribution, course=private_course, contributor=responsible, can_edit=True, responsible=True, comment_visibility=Contribution.ALL_COMMENTS)
mommy.make(Contribution, course=private_course, contributor=contributor, can_edit=True)
url = '/results/semester/%s' % (self.semester.id)
page = self.app.get(url, user='random')
self.assertNotIn(private_course.name, page)
page = self.app.get(url, user='student')
self.assertIn(private_course.name, page)
page = self.app.get(url, user='responsible')
self.assertIn(private_course.name, page)
page = self.app.get(url, user='contributor')
self.assertIn(private_course.name, page)
page = self.app.get(url, user='evap')
self.assertIn(private_course.name, page)
url = '/results/semester/%s/course/%s' % (self.semester.id, private_course.id)
self.get_assert_403(url, "random")
self.get_assert_200(url, "student")
self.get_assert_200(url, "responsible")
self.get_assert_200(url, "contributor")
self.get_assert_200(url, "evap")
开发者ID:JenniferStamm,项目名称:EvaP,代码行数:30,代码来源:test_views.py
示例20: test_recipient_list_filtering
def test_recipient_list_filtering(self):
course = mommy.make(Course)
contributor1 = mommy.make(UserProfile)
contributor2 = mommy.make(UserProfile, delegates=[contributor1])
mommy.make(Contribution, course=course, contributor=contributor1)
mommy.make(Contribution, course=course, contributor=contributor2)
# no-one should get filtered.
recipient_list = EmailTemplate.recipient_list_for_course(course, [EmailTemplate.CONTRIBUTORS], filter_users_in_cc=False)
self.assertCountEqual(recipient_list, [contributor1, contributor2])
# contributor1 is in cc of contributor2 and gets filtered.
recipient_list = EmailTemplate.recipient_list_for_course(course, [EmailTemplate.CONTRIBUTORS], filter_users_in_cc=True)
self.assertCountEqual(recipient_list, [contributor2])
contributor3 = mommy.make(UserProfile, delegates=[contributor2])
mommy.make(Contribution, course=course, contributor=contributor3)
# again, no-one should get filtered.
recipient_list = EmailTemplate.recipient_list_for_course(course, [EmailTemplate.CONTRIBUTORS], filter_users_in_cc=False)
self.assertCountEqual(recipient_list, [contributor1, contributor2, contributor3])
# contributor1 is in cc of contributor2 and gets filtered.
# contributor2 is in cc of contributor3 but is not filtered since contributor1 wouldn't get an email at all then.
recipient_list = EmailTemplate.recipient_list_for_course(course, [EmailTemplate.CONTRIBUTORS], filter_users_in_cc=True)
self.assertCountEqual(recipient_list, [contributor2, contributor3])
开发者ID:Steditor,项目名称:EvaP,代码行数:28,代码来源:test_models.py
注:本文中的model_mommy.mommy.make函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论