django_dynamic_fixture.G

Here are the examples of the python api django_dynamic_fixture.G taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

189 Examples 7

Example 1

Project: onlineweb4 Source File: tests.py
    def testMommyPaymentDelayExcluding(self):
        G(Attendee, event=self.attendance_event, user=self.user)
        not_paid = PaymentReminder.not_paid(self.event_payment)

        self.assertEqual([self.user], not_paid)

        G(
            PaymentDelay,
            payment=self.event_payment,
            user=self.user,
            valid_to=timezone.now() + timedelta(days=1)
        )

        not_paid = PaymentReminder.not_paid(self.event_payment)

        self.assertFalse(not_paid)

Example 2

Project: django-accounting Source File: invoice_tests.py
    def test_returns_correct_turnovers(self):
        invoice1 = G(Invoice,
            number=101,
            total_excl_tax=D('10.00'),
            total_incl_tax=D('12.00'))

        invoice2 = G(Invoice,
            number=102,
            total_excl_tax=D('5.00'),
            total_incl_tax=D('6.00'))

        queryset = Invoice.objects.all()
        self.assertEqual(queryset.turnover_excl_tax(), D('10.00') + D('5.00'))
        self.assertEqual(queryset.turnover_incl_tax(), D('12.00') + D('6.00'))

Example 3

Project: onlineweb4 Source File: tests.py
    def testAttendeeAndWaitlistQS(self):
        self.logger.debug("Testing attendee queryset")
        user1 = G(User, username="jan", first_name="jan")
        G(Attendee, event=self.attendance_event, user=user1)
        user2 = G(User, username="per", first_name="per")
        G(Attendee, event=self.attendance_event, user=user2)
        user3 = G(User, username="gro", first_name="gro")
        G(Attendee, event=self.attendance_event, user=user3)
        self.assertEqual(self.attendance_event.max_capacity, 2)
        self.assertEqual(self.attendance_event.number_of_attendees, 2)
        self.assertEqual(self.attendance_event.number_on_waitlist, 2)

Example 4

Project: onlineweb4 Source File: tests.py
    def testEventPaymentRefund(self):
        G(Attendee, event=self.attendance_event, user=self.user)
        self.event_payment.handle_payment(self.user)

        payment_relation = G(
            PaymentRelation,
            payment=self.event_payment,
            user=self.user,
            payment_price=self.payment_price
        )
        self.assertFalse(payment_relation.refunded)

        self.event_payment.handle_refund("host", payment_relation)
        attendees = Attendee.objects.all()

        self.assertTrue(payment_relation.refunded)
        self.assertEqual(set([]), set(attendees))

Example 5

Project: onlineweb4 Source File: tests.py
    def test_registration_no_push_forward(self):
        """
        Tests that an AttendanceEvent with registration date far in the future is sorted by its event end date,
        like any other event.
        """
        today = timezone.now()
        month_ahead = today + datetime.timedelta(days=30)
        month_ahead_plus_five = month_ahead + datetime.timedelta(days=5)
        normal_event = G(Event, event_start=month_ahead, event_end=month_ahead)
        pushed_event = G(Event, event_start=month_ahead_plus_five, event_end=month_ahead_plus_five)
        G(AttendanceEvent, registration_start=month_ahead_plus_five, registration_end=month_ahead_plus_five,
          event=pushed_event)

        expected_order = [normal_event, pushed_event]

        with override_settings(settings=self.FEATURED_TIMEDELTA_SETTINGS):
            self.assertEqual(list(Event.by_registration.all()), expected_order)

Example 6

Project: onlineweb4 Source File: tests.py
    def test_careeropportunity_detail(self):
        past = datetime(2000, 1, 1)
        future = timezone.now() + timedelta(days=1)
        careeropportunity = G(CareerOpportunity, start=past, end=future)

        url = reverse('careeropportunity_details', args=(careeropportunity.id,))

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 7

Project: onlineweb4 Source File: tests.py
    def test_calendar_export(self):
        G(SplashEvent)
        url = reverse('splash_calendar')

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 8

Project: django-ondelta Source File: tests.py
Function: test_g
    def test_g(self):
        foo = G(Foo, char_field='foo')
        foo.char_field = 'bar'
        foo.save()
        foo.char_field = 'baz'
        foo.save()
        self.assertEqual(foo.char_field_delta_count, 2)

Example 9

Project: django-accounting Source File: organization_tests.py
    def test_debts_excl_tax_is_valid(self):
        bill1 = G(Bill,
            number=101,
            total_excl_tax=D('10.00'),
            total_incl_tax=D('12.00'))
        bill2 = G(Bill,
            number=102,
            total_excl_tax=D('30.00'),
            total_incl_tax=D('40.00'))
        self.organization.bills.add(bill1)
        self.organization.bills.add(bill2)
        self.assertEqual(self.organization.debts_excl_tax,
            D('10.00') + D('30.00'))

Example 10

Project: onlineweb4 Source File: tests.py
    def test_article_archive_exists(self):
        G(Article)

        url = reverse('article_archive')

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 11

Project: onlineweb4 Source File: tests.py
    def testEventPaymentRefundCheckEventStarted(self):
        G(Attendee, event=self.attendance_event, user=self.user)
        payment_relation = G(
            PaymentRelation,
            payment=self.event_payment,
            user=self.user,
            payment_price=self.payment_price
        )

        self.event.event_start = timezone.now() - timedelta(days=1)
        self.event.save()

        self.assertFalse(self.event_payment.check_refund(payment_relation)[0])

Example 12

Project: onlineweb4 Source File: tests.py
    def test_registration_past_push_forward(self):
        """
        Tests that an AttendanceEvent with a registration date in the past, outside the "featured delta" (+/- 7 days)
        will be sorted by the event's end date.
        """
        today = timezone.now()
        month_ahead = today + datetime.timedelta(days=30)
        month_ahead_plus_five = month_ahead + datetime.timedelta(days=5)
        month_back = today - datetime.timedelta(days=30)
        normal_event = G(Event, event_start=month_ahead, event_end=month_ahead)
        pushed_event = G(Event, event_start=month_ahead_plus_five, event_end=month_ahead_plus_five)
        G(AttendanceEvent, registration_start=month_back, registration_end=month_back, event=pushed_event)

        expected_order = [normal_event, pushed_event]

        with override_settings(settings=self.FEATURED_TIMEDELTA_SETTINGS):
            self.assertEqual(list(Event.by_registration.all()), expected_order)

Example 13

Project: onlineweb4 Source File: tests.py
    def test_article_list_exists(self):
        url = reverse('article-list')

        G(Article)

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 14

Project: onlineweb4 Source File: tests.py
    def testEventMommyPaid(self):
        G(Attendee, event=self.attendance_event, user=self.user)
        G(PaymentRelation, payment=self.event_payment, user=self.user, payment_price=self.payment_price)
        not_paid = PaymentReminder.not_paid(self.event_payment)

        self.assertFalse(not_paid)

Example 15

Project: django-adminactions Source File: test_byrows_update.py
Function: set_up
    def setUp(self):
        super(TestByRowsUpdateAction, self).setUp()
        self._url = reverse('admin:demo_demomodel_changelist')
        self.user = G(User, username='user', is_staff=True, is_active=True)
        self.site = AdminSite()
        self.mockRequest = MockRequest()

Example 16

Project: onlineweb4 Source File: tests.py
    def test_item_list_exists(self):
        G(Item, available=True)
        url = reverse('item-list')

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 17

Project: onlineweb4 Source File: tests.py
def create_generic_event():
        future = timezone.now() + datetime.timedelta(days=1)
        event_start = future
        event_end = future + datetime.timedelta(days=1)
        event = G(Event, event_start=event_start, event_end=event_end)

        return event

Example 18

Project: onlineweb4 Source File: tests.py
    def test_splash_events_list_filter_future(self):
        last_week = datetime.datetime.now() - datetime.timedelta(days=7)
        next_week = datetime.datetime.now() + datetime.timedelta(days=7)

        G(SplashEvent, start_time=last_week, end_time=last_week)
        next_week_event = G(SplashEvent, start_time=next_week, end_time=next_week)

        url = reverse('splashevent-list')

        url += '?start_time__gte=%s' % datetime.datetime.now()

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(1, response.data.get('count'))
        self.assertEqual(next_week_event.title, response.data.get('results')[0].get('title'))

Example 19

Project: django-adminactions Source File: conftest.py
Function: users
@pytest.fixture(scope='function')
def users():
    from django.contrib.auth.models import User
    from django_dynamic_fixture import G

    return G(User, n=2, is_staff=False, is_active=False)

Example 20

Project: django-accounting Source File: organization_tests.py
    def test_turnover_incl_tax_is_valid(self):
        invoice1 = G(Invoice,
            number=101,
            total_excl_tax=D('10.00'),
            total_incl_tax=D('12.00'))
        invoice2 = G(Invoice,
            number=102,
            total_excl_tax=D('30.00'),
            total_incl_tax=D('40.00'))
        self.organization.invoices.add(invoice1)
        self.organization.invoices.add(invoice2)
        self.assertEqual(self.organization.turnover_incl_tax,
            D('12.00') + D('40.00'))

Example 21

Project: onlineweb4 Source File: tests.py
    def testNumberOfTakenSeats(self):
        # Increase event capacity so we have more room to test with
        self.attendance_event.max_capacity = 5
        self.assertEqual(self.attendance_event.number_of_attendees, 1)
        # Make a reservation, for 2 seats
        reservation = G(Reservation, attendance_event=self.attendance_event, seats=2)
        G(Reservee, reservation=reservation, name="jan", note="jan er kul", allergies="allergi1")
        self.assertEqual(self.attendance_event.max_capacity, 5)
        self.assertEqual(self.attendance_event.number_of_attendees, 1)
        self.assertEqual(self.attendance_event.number_of_reserved_seats_taken, 1)
        self.assertEqual(self.attendance_event.number_of_seats_taken, 3)
        G(Reservee, reservation=reservation, name="per", note="per er rå", allergies="allergi2")
        self.assertEqual(self.attendance_event.number_of_attendees, 1)
        self.assertEqual(self.attendance_event.number_of_reserved_seats_taken, 2)
        self.assertEqual(self.attendance_event.number_of_seats_taken, 3)
        user3 = G(User, username="gro", first_name="gro")
        G(Attendee, event=self.attendance_event, user=user3)
        self.assertEqual(self.attendance_event.number_of_attendees, 2)
        self.assertEqual(self.attendance_event.number_of_seats_taken, 4)

Example 22

Project: onlineweb4 Source File: tests.py
    def testSignUpWithNoRulesAndAMark(self):
        self.logger.debug("Testing signup with no rules and a mark.")

        # Giving the user a mark to see if the status goes to False.
        mark1 = G(Mark, title='Testprikk12345')
        G(MarkUser, user=self.user, mark=mark1, expiration_date=self.now+datetime.timedelta(days=DURATION))
        response = self.attendance_event.is_eligible_for_signup(self.user)
        self.assertFalse(response['status'])
        self.assertEqual(401, response['status_code'])

Example 23

Project: django-adminactions Source File: conftest.py
@pytest.fixture(scope='function')
def demomodels():
    from django_dynamic_fixture import G
    from demo.models import DemoModel

    return G(DemoModel, n=20)

Example 24

Project: onlineweb4 Source File: tests.py
    def test_registration_start_pushed_forward(self):
        """
        Tests that an AttendanceEvent with registration date within the "featured delta" (+/- 7 days from today)
        will be pushed ahead in the event list, thus sorted by registration start rather than event end.
        """
        today = timezone.now()
        three_days_ahead = today + datetime.timedelta(days=3)
        month_ahead = today + datetime.timedelta(days=30)
        month_ahead_plus_five = month_ahead + datetime.timedelta(days=5)
        normal_event = G(Event, event_start=month_ahead, event_end=month_ahead)
        pushed_event = G(Event, event_start=month_ahead_plus_five, event_end=month_ahead_plus_five)
        G(AttendanceEvent, registration_start=three_days_ahead, registration_end=three_days_ahead, event=pushed_event)

        expected_order = [pushed_event, normal_event]

        with override_settings(settings=self.FEATURED_TIMEDELTA_SETTINGS):
            self.assertEqual(list(Event.by_registration.all()), expected_order)

Example 25

Project: onlineweb4 Source File: tests.py
Function: test_article_detail
    def test_article_detail(self):
        article = G(Article)

        url = reverse('article_details', args=(article.id, article.slug))

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 26

Project: onlineweb4 Source File: tests.py
    def testEventPaymentRefundCheckAtendeeExists(self):
        payment_relation = G(
            PaymentRelation,
            payment=self.event_payment,
            user=self.user,
            payment_price=self.payment_price
        )

        self.assertFalse(self.event_payment.check_refund(payment_relation)[0])

Example 27

Project: onlineweb4 Source File: tests.py
    def testEventPaymentCompleteModifyAttendee(self):
        G(Attendee, event=self.attendance_event, user=self.user)
        self.event_payment.handle_payment(self.user)

        attendee = Attendee.objects.all()[0]

        self.assertTrue(attendee.paid)

Example 28

Project: onlineweb4 Source File: tests.py
    def test_article_archive_month_exists(self):
        created_date = datetime.datetime(2013, 1, 1)
        G(Article, created_date=created_date, published_date=created_date)

        url = reverse('article_archive_month', args=(2013, 'Januar'))

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 29

Project: onlineweb4 Source File: tests.py
    def testEventPaymentRefundCheck(self):
        G(Attendee, event=self.attendance_event, user=self.user)
        self.attendance_event.unattend_deadline = timezone.now() + timedelta(days=1)
        self.attendance_event.save()

        self.event.event_start = timezone.now() + timedelta(days=1)
        self.event.save()

        payment_relation = G(
            PaymentRelation,
            payment=self.event_payment,
            user=self.user,
            payment_price=self.payment_price
        )

        print(self.event_payment.check_refund(payment_relation))
        self.assertTrue(self.event_payment.check_refund(payment_relation)[0])

Example 30

Project: django-adminactions Source File: conftest.py
@pytest.fixture(scope='function')
def admin_site(browser, administrator):
    from demo.models import DemoModel, UserDetail

    G(DemoModel, n=5)
    G(UserDetail, n=5)
    login(browser)
    return browser, administrator

Example 31

Project: onlineweb4 Source File: tests.py
    def testEventMommyNotPaid(self):
        G(Attendee, event=self.attendance_event, user=self.user)
        attendees = [attendee.user for attendee in Attendee.objects.all()]
        not_paid = PaymentReminder.not_paid(self.event_payment)

        self.assertEqual(attendees, not_paid)

Example 32

Project: onlineweb4 Source File: tests.py
Function: test_article_detail
    def test_article_detail(self):
        in_the_past = datetime.datetime(2000, 1, 1, 0, 0, 0)

        article = G(Article, created_date=in_the_past, published_date=in_the_past)

        url = reverse('article-detail', args=(article.id,))

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 33

Project: onlineweb4 Source File: tests.py
    def testMommyPaymentDelay(self):
        G(Attendee, event=self.attendance_event, user=self.user)
        payment_delay = G(
            PaymentDelay,
            payment=self.event_payment,
            user=self.user,
            valid_to=timezone.now() + timedelta(days=1)
        )

        self.assertTrue(payment_delay.active)

        PaymentDelayHandler.handle_deadline_passed(payment_delay, False)

        self.assertFalse(payment_delay.active)

Example 34

Project: django-twilio Source File: models.py
Function: set_up
    def setUp(self):
        self.user = G(User, username='test', password='pass')
        self.credentials = G(
            Credential,
            name='Test Credentials',
            account_sid='XXX',
            auth_token='YYY',
            user=self.user,
        )

Example 35

Project: onlineweb4 Source File: tests.py
Function: test_user_search
    def test_user_search(self):
        user = G(User)
        url = reverse('profiles_user_search')

        self.client.force_login(user)

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 36

Project: onlineweb4 Source File: tests.py
    def test_company_profile_detail(self):
        company = G(Company)

        url = reverse('company_details', args=(company.id,))

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 37

Project: onlineweb4 Source File: tests.py
    def test_item_detail(self):
        item = G(Item, available=True)
        url = reverse('item-detail', args=(item.id,))

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 38

Project: django-adminactions Source File: utils.py
Function: get_group
def get_group(name=None, permissions=None):
    group = G(Group, name=(name or text(5)))
    permission_names = permissions or []
    for permission_name in permission_names:
        try:
            app_label, codename = permission_name.split('.')
        except ValueError:
            raise ValueError("Invalid permission name `{0}`".format(permission_name))
        try:
            permission = Permission.objects.get(content_type__app_label=app_label, codename=codename)
        except Permission.DoesNotExist:
            raise Permission.DoesNotExist('Permission `{0}` does not exist'.format(permission_name))

        group.permissions.add(permission)
    return group

Example 39

Project: onlineweb4 Source File: tests.py
    def test_splash_events_list_with_events_exist(self):
        G(SplashEvent)
        url = reverse('splashevent-list')

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 40

Project: onlineweb4 Source File: tests.py
Function: set_up
    def setUp(self):
        self.event = G(Event, title='Sjakkturnering')
        self.attendance_event = G(AttendanceEvent, event=self.event, max_capacity=2)
        self.user = G(User, username='ola123', ntnu_username='ola123ntnu', first_name="ola", last_name="nordmann")
        self.attendee = G(Attendee, event=self.attendance_event, user=self.user)
        self.logger = logging.getLogger(__name__)
        # Setting registration start 1 hour in the past, end one week in the future.
        self.now = timezone.now()
        self.attendance_event.registration_start = self.now - datetime.timedelta(hours=1)
        self.attendance_event.registration_end = self.now + datetime.timedelta(days=7)
        # Making the user a member.
        self.allowed_username = G(AllowedUsername, username='ola123ntnu',
                                  expiration_date=self.now + datetime.timedelta(weeks=1))

Example 41

Project: django-accounting Source File: bill_tests.py
    def test_returns_correct_turnovers(self):
        invoice1 = G(Bill,
            number=101,
            total_excl_tax=D('10.00'),
            total_incl_tax=D('12.00'))

        invoice2 = G(Bill,
            number=102,
            total_excl_tax=D('5.00'),
            total_incl_tax=D('6.00'))

        queryset = Bill.objects.all()
        self.assertEqual(queryset.debts_excl_tax(), D('10.00') + D('5.00'))
        self.assertEqual(queryset.debts_incl_tax(), D('12.00') + D('6.00'))

Example 42

Project: django-twilio Source File: decorators.py
    def setUp(self):

        self.regular_caller = G(Caller, phone_number='+12222222222', blacklisted=False)
        self.blocked_caller = G(Caller, phone_number='+13333333333', blacklisted=True)

        self.factory = TwilioRequestFactory(
            token=settings.TWILIO_AUTH_TOKEN,
            enforce_csrf_checks=True,
        )

        # Test URIs.
        self.str_uri = '/test_app/decorators/str_view/'
        self.str_class_uri = '/test_app/decorators/str_class_view/'
        self.bytes_uri = '/test_app/decorators/bytes_view/'
        self.bytes_class_uri = '/test_app/decorators/bytes_class_view/'
        self.verb_uri = '/test_app/decorators/verb_view/'
        self.verb_class_uri = 'test_app/decorators/verb_class_view/'
        self.response_uri = '/test_app/decorators/response_view/'
        self.response_class_uri = 'test_app/decorators/response_class_view/'

Example 43

Project: django-accounting Source File: organization_tests.py
    def test_turnover_excl_tax_is_valid(self):
        invoice1 = G(Invoice,
            number=101,
            total_excl_tax=D('10.00'),
            total_incl_tax=D('12.00'))
        invoice2 = G(Invoice,
            number=102,
            total_excl_tax=D('30.00'),
            total_incl_tax=D('40.00'))
        self.organization.invoices.add(invoice1)
        self.organization.invoices.add(invoice2)
        self.assertEqual(self.organization.turnover_excl_tax,
            D('10.00') + D('30.00'))

Example 44

Project: onlineweb4 Source File: tests.py
    def testReservedSeats(self):
        self.logger.debug("Testing reserved seats")
        reservation = G(Reservation, attendance_event=self.attendance_event, seats=2)
        G(Reservee, reservation=reservation, name="jan", note="jan er kul", allergies="allergi1")
        self.assertEqual(self.attendance_event.number_of_reserved_seats_taken, 1)
        G(Reservee, reservation=reservation, name="per", note="per er rå", allergies="allergi2")
        self.assertEqual(self.attendance_event.number_of_reserved_seats_taken, 2)

Example 45

Project: onlineweb4 Source File: tests.py
Function: set_up
    def setUp(self):
        self.applicant = G(User, username="sokeren", first_name="Søker", last_name="Søkersen")
        self.approval = G(MembershipApproval, applicant=self.applicant)
        self.approval.new_expiry_date = None
        self.approval.field_of_study = 0
        self.approval.started_date = None
        self.logger = logging.getLogger(__name__)

Example 46

Project: django-twilio Source File: client.py
    def test_twilio_client_with_credentials_model(self):
        self.user = G(User, username='test', password='pass')
        self.credentials = G(
            Credential,
            name='Test Credentials',
            account_sid='AAA',
            auth_token='BBB',
            user=self.user,
        )

        credentials = discover_twilio_credentials(user=self.user)

        self.assertEquals(credentials[0], self.credentials.account_sid)
        self.assertEquals(credentials[1], self.credentials.auth_token)

Example 47

Project: django-twilio Source File: models.py
Function: set_up
    def setUp(self):
        self.caller = G(
            Caller,
            phone_number='12223334444',
            blacklisted=False,
        )

Example 48

Project: django-adminactions Source File: conftest.py
Function: admin
@pytest.fixture(scope='function')
def admin():
    from django_dynamic_fixture import G
    from django.contrib.auth.models import User

    return G(User, is_staff=True, is_active=True)

Example 49

Project: onlineweb4 Source File: tests.py
    def test_article_archive_year_exists(self):
        created_date = datetime.datetime(2013, 1, 1)
        G(Article, created_date=created_date, published_date=created_date)

        url = reverse('article_archive_year', args=(2013,))

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

Example 50

Project: onlineweb4 Source File: tests.py
    def testEventPaymentRefundCheckUnatendDeadlinePassed(self):
        G(Attendee, event=self.attendance_event, user=self.user)
        payment_relation = G(
            PaymentRelation,
            payment=self.event_payment,
            user=self.user,
            payment_price=self.payment_price
        )

        self.attendance_event.unattend_deadline = timezone.now() - timedelta(days=1)
        self.attendance_event.save()

        self.assertFalse(self.event_payment.check_refund(payment_relation)[0])
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3 Page 4