How to use mixer - 10 common examples

To help you get started, we’ve selected a few mixer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github klen / mixer / tests / test_main.py View on Github external
def test_factory():
    """ Test base generator's factory. """
    from mixer.main import GenFactory

    g = GenFactory()
    test = g.get_fabric(int)
    assert -2147483647 <= test() < 2147483647

    test = g.get_fabric(bool)
    assert test() in (True, False)
github doccano / doccano / app / server / tests.py View on Github external
def test_uniqueness(self):
        annotation1 = mixer.blend('server.SequenceAnnotation')
        with self.assertRaises(IntegrityError):
            mixer.blend('server.SequenceAnnotation',
                        document=annotation1.document,
                        user=annotation1.user,
                        label=annotation1.label,
                        start_offset=annotation1.start_offset,
                        end_offset=annotation1.end_offset)
github dbca-wa / oim-cms / oim_cms / test_api.py View on Github external
def setUp(self):
        # Generate some other DepartmentUser objects.
        mixer.cycle(8).blend(
            DepartmentUser, username=mixer.RANDOM, photo=None, active=True,
            email=random_dbca_email, org_unit=None,
            cost_centre=None, ad_guid=uuid1, o365_licence=False, in_sync=False)
        # Generate some locations.
        self.loc1 = mixer.blend(Location, manager=None)
        self.loc2 = mixer.blend(Location, manager=None)
        # Generate a basic org structure.
        # NOTE: don't use mixer to create OrgUnit objects (it breaks MPTT).
        self.dept = OrgUnit.objects.create(name='Department 1', unit_type=0, acronym='DEPT', active=True)
        self.div1 = OrgUnit.objects.create(
            name='Divison 1', unit_type=1, parent=self.dept, location=self.loc1, acronym='DIV1', active=True)
        self.branch1 = OrgUnit.objects.create(
            name='Branch 1', unit_type=2, parent=self.div1, location=self.loc1, acronym='BRANCH1', active=True)
        self.cc1 = CostCentre.objects.create(
            name='Cost centre 1', code='001', division=self.div1, org_position=self.div1)
        self.div2 = OrgUnit.objects.create(
            name='Divison 2', unit_type=1, parent=self.dept, location=self.loc2, acronym='DIV2', active=True)
        self.branch2 = OrgUnit.objects.create(
            name='Branch 2', unit_type=2, parent=self.div2, location=self.loc2, acronym='BRANCH2', active=True)
        self.cc2 = CostCentre.objects.create(
            name='Cost centre 2', code='002', division=self.div2, org_position=self.div2)
        # Give each of the org units some members.
github dbca-wa / oim-cms / registers / test_api.py View on Github external
def setUp(self):
        super(ITSystemEventResourceTestCase, self).setUp()
        # Create some events
        self.event_current = mixer.blend(ITSystemEvent, planned=False, start=timezone.now())
        self.event_past = mixer.blend(
            ITSystemEvent, planned=True, start=timezone.now() - timedelta(hours=1),
            end=timezone.now(), current=False)
github dbca-wa / oim-cms / knowledge / test_views.py View on Github external
def setUp(self):
        # Create User and linked DepartmentUser objects.
        self.du1 = mixer.blend(DepartmentUser, photo=None)
        self.user1 = User.objects.create_user(
            username=self.du1.username, email=self.du1.email)
        self.user1.is_superuser = True
        self.user1.set_password('pass')
        self.user1.save()
        # Log in user1 by default.
        self.client.login(username=self.user1.username, password='pass')
        self.du2 = mixer.blend(DepartmentUser, photo=None)
        self.user2 = User.objects.create_user(
            username=self.du2.username, email=self.du2.email)
        self.user2.set_password('pass')
        self.user2.save()
        self.itsystem = mixer.blend(ITSystem, system_id='S001')
github dbca-wa / oim-cms / knowledge / test_views.py View on Github external
# Create User and linked DepartmentUser objects.
        self.du1 = mixer.blend(DepartmentUser, username=mixer.RANDOM, photo=None)
        self.user1 = User.objects.create_user(
            username=self.du1.username, email=self.du1.email)
        self.user1.is_superuser = True
        self.user1.set_password('pass')
        self.user1.save()
        # Log in user1 by default.
        self.client.login(username=self.user1.username, password='pass')
        self.du2 = mixer.blend(DepartmentUser, username=mixer.RANDOM, photo=None)
        self.user2 = User.objects.create_user(
            username=self.du2.username, email=self.du2.email)
        self.user2.set_password('pass')
        self.user2.save()

        self.itsystem = mixer.blend(ITSystem)
github klen / adrest / tests / main / tests.py View on Github external
def test_options(self):
        self.assertTrue('OPTIONS' in ArticleResource._meta.allowed_methods)
        uri = self.reverse('author-test-book-article', book=self.book.pk)
        response = self.client.options(uri, data=dict(author=self.author.pk))
        self.assertContains(response, 'OK')

        author = mixer.blend('main.author')
        response = self.client.options(uri, data=dict(author=author.pk))
        self.assertContains(response, 'OK')
github dbca-wa / oim-cms / registers / test_admin.py View on Github external
def setUp(self):
        super(RegistersAdminTestCase, self).setUp()
        # Create an admin user.
        self.admin_user = mixer.blend(User, username='admin', is_superuser=True, is_staff=True)
        self.admin_user.set_password('pass')
        self.admin_user.save()
        # Create some Computers
        self.com1 = mixer.blend(Computer)
        self.com2 = mixer.blend(Computer)
        # Create some ITSystemHardware objects
        self.itsys1 = mixer.blend(ITSystemHardware, computer=self.com1, production=True)
        self.itsys2 = mixer.blend(ITSystemHardware, computer=self.com2)
        # Attach ITSystemHardware to ITSystem objects.
        self.it1.hardwares.add(self.itsys1)
        self.it2.hardwares.add(self.itsys2)
        # Log in as admin user by default
        self.client.login(username='admin', password='pass')
github dbca-wa / oim-cms / registers / test_admin.py View on Github external
def setUp(self):
        super(RegistersAdminTestCase, self).setUp()
        # Create an admin user.
        self.admin_user = mixer.blend(User, username='admin', is_superuser=True, is_staff=True)
        self.admin_user.set_password('pass')
        self.admin_user.save()
        # Create some Computers
        self.com1 = mixer.blend(Computer)
        self.com2 = mixer.blend(Computer)
        # Create some ITSystemHardware objects
        self.itsys1 = mixer.blend(ITSystemHardware, computer=self.com1, production=True)
        self.itsys2 = mixer.blend(ITSystemHardware, computer=self.com2)
        # Attach ITSystemHardware to ITSystem objects.
        self.it1.hardwares.add(self.itsys1)
        self.it2.hardwares.add(self.itsys2)
        # Log in as admin user by default
        self.client.login(username='admin', password='pass')
github se-curriculum-design-group / 2019-Software-Engineering-Curriculum-Design / EMS / courseSelection / tests.py View on Github external
def setUp(self) -> None:
        teacher = mixer.blend(Teacher)
        teacher.username = '198500038'
        teacher.password = make_encode('198500038')
        teacher.save()
        self.log_data = {
            'username': teacher.username,
            'password': teacher.username
        }
        data = {
            'username': '198500038',
            'password': '198500038'
        }

        url = ""
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'login.html')