コード例 #1
0
ファイル: __init__.py プロジェクト: MailBeaker/beaker
class BaseTestCase(APITestCase):

    def setUp(self):
        """
        Sets up a number of test entites in the database for testing.

        Included:
            user: A webapp user
            organization: An organization that user belongs to
            domain: A domain that belongs to organization
        """

        # Creating Users
        self.user = MBUser(
            email='*****@*****.**',
            first_name='test',
            last_name='tester',
            is_admin=False,
            is_platform=False,
            is_webapp=True,
        )

        self.user.set_password('test')
        self.user.save()

        self.client.login(username='******', password='******')

        # Organization
        self.organization = Organization(
            name='Test Organization',
            address_1='123 Any Street',
            address_2='Suite 001',
            city='New York',
            state='NY',
            phone='555-555-1234'
        )
        self.organization.save()

        self.user_meta = UserMeta(
            user=self.user,
            organization=self.organization
        )
        self.user_meta.save()

        # Domain
        self.domain = Domain(
            domain_name='test.com',
            organization=self.organization,
            whitelisted=False
        )
        self.domain.save()
コード例 #2
0
ファイル: views.py プロジェクト: MailBeaker/beaker
    def get_queryset(self):
        domain_id = self.kwargs.get('pk')
        if not domain_id:
            raise Http404

        domain = Domain.get_by_id(domain_id)

        metas = UserMeta.objects.filter(organization=domain.organization)
        return [meta.user for meta in metas]
コード例 #3
0
    def handle(self, *args, **options):

        # Create the organization
        org = Organization(**organization).save()
        if not org:
            self.stdout.write("Org failed")
            return

        self.stdout.write("Successfully created the MailBeaker organization")

        # Create the domain in the organization
        dom = Domain(organization=org, **domain)
        self.stdout.write("Successfully created the MailBeaker domain")

        # Create all of the users in the domain
        for user in users:
            mb_user = MBUser(**user).save()
            user_meta = UserMeta(user=mb_user, organization=org)
            self.stdout.write("Successfully created the %s user and associated meta" % mb_user.email)

        # Create all of the rules
        for rule in rules:
            rule_entity = Rule(domain=dom, **rule)
            self.stdout.write("Successfully created the rule: %s" % rule['description'])