コード例 #1
0
def insert_a_user(email=None, department=None, role=None):
    role = role if role else RoleFactory.create()
    try:
        if email:
            user = UserFactory.create(email=email, role=role, department=department)
        else:
            user = UserFactory.create(role=role, department=department)
        return user
    except IntegrityError:
        db.session.rollback()
        return User.query.filter(User.email == email).first()
コード例 #2
0
def insert_a_user(email=None, department=None, role=None):
    role = role if role else RoleFactory.create()
    try:
        if email:
            user = UserFactory.create(email=email,
                                      role=role,
                                      department=department)
        else:
            user = UserFactory.create(role=role, department=department)
        return user
    except IntegrityError:
        db.session.rollback()
        return User.query.filter(User.email == email).first()
 def test_can_edit_is_public(self):
     staff = UserFactory.build(roles=[RoleFactory.build(name='staff')])
     creator = UserFactory.build(roles=[RoleFactory.build(name='staff')])
     admin = UserFactory.build(roles=[RoleFactory.build(name='admin')])
     opportunity = OpportunityFactory.build(
         is_public=True, planned_publish=self.yesterday,
         planned_submission_start=self.today, planned_submission_end=self.tomorrow,
         created_by=creator, created_by_id=creator.id,
         contact_id=creator.id
     )
     self.assertFalse(opportunity.can_edit(staff))
     self.assertFalse(opportunity.can_edit(creator))
     self.assertTrue(opportunity.can_edit(admin))
 def test_can_edit_is_public(self):
     staff = UserFactory.build(role=RoleFactory.build(name='staff'))
     creator = UserFactory.build(role=RoleFactory.build(name='staff'))
     admin = UserFactory.build(role=RoleFactory.build(name='admin'))
     opportunity = OpportunityFactory.build(
         is_public=True,
         planned_publish=self.yesterday,
         planned_submission_start=self.today,
         planned_submission_end=self.tomorrow,
         created_by=creator,
         created_by_id=creator.id,
         contact_id=creator.id)
     self.assertFalse(opportunity.can_edit(staff))
     self.assertFalse(opportunity.can_edit(creator))
     self.assertTrue(opportunity.can_edit(admin))
コード例 #5
0
def insert_a_user(email=None, department=None, role=None, pw="password"):
    role = role if role else RoleFactory.create()
    try:
        if email:
            user = UserFactory.create(
                email=email, roles=[role], department=department, confirmed_at=datetime.datetime.now(), password=pw
            )
        else:
            user = UserFactory.create(
                roles=[role], department=department, password=pw, confirmed_at=datetime.datetime.now()
            )
        return user
    except IntegrityError:
        db.session.rollback()
        return User.query.filter(User.email == email).first()
コード例 #6
0
    def setUp(self):
        super(TestBeaconJobs, self).setUp()

        self.yesterday = datetime.datetime.today() - datetime.timedelta(days=1)
        today = datetime.datetime.today()
        tomorrow = datetime.datetime.today() + datetime.timedelta(days=1)

        self.category = CategoryFactory.create()
        admin_role = RoleFactory.create(name='admin')
        self.admin = UserFactory.create(roles=[admin_role])

        self.opportunity = OpportunityFactory.create(
            is_public=True, planned_publish=today, planned_submission_start=today,
            planned_submission_end=tomorrow, categories=set([self.category]),
            created_by=self.admin, published_at=today
        )
        self.opportunity2 = OpportunityFactory.create(
            is_public=True, planned_publish=self.yesterday, planned_submission_start=today,
            planned_submission_end=tomorrow, publish_notification_sent=True,
            categories=set([self.category]), created_by=self.admin, published_at=self.yesterday
        )
        self.opportunity3 = OpportunityFactory.create(
            is_public=False, planned_publish=today, planned_submission_start=today,
            planned_submission_end=tomorrow, publish_notification_sent=False,
            categories=set([self.category]), created_by=self.admin, published_at=today
        )
        self.opportunity4 = OpportunityFactory.create(
            is_public=True, planned_publish=self.yesterday, planned_submission_start=self.yesterday,
            planned_submission_end=today, publish_notification_sent=True,
            categories=set([self.category]), created_by=self.admin, published_at=self.yesterday
        )

        VendorFactory.create(opportunities=set([self.opportunity]))
        VendorFactory.create(categories=set([self.category]))
コード例 #7
0
def insert_a_user(email=None, department=None, role=None, pw='password'):
    role = role if role else RoleFactory.create()
    try:
        if email:
            user = UserFactory.create(
                email=email, roles=[role], department=department,
                confirmed_at=datetime.datetime.now(),
                password=pw
            )
        else:
            user = UserFactory.create(
                roles=[role], department=department,
                password=pw, confirmed_at=datetime.datetime.now()
            )
        return user
    except IntegrityError:
        db.session.rollback()
        return User.query.filter(User.email == email).first()
コード例 #8
0
    def setUp(self):
        super(TestScoutJobs, self).setUp()
        self.user = UserFactory.create()
        ContractBaseFactory.create(
            expiration_date=datetime.date.today() + datetime.timedelta(30), description="foobar", followers=[self.user]
        )

        ContractBaseFactory.create(expiration_date=datetime.date.today(), description="qux", followers=[self.user])

        ContractBaseFactory.create(
            expiration_date=datetime.date.today() + datetime.timedelta(1), description="qux", followers=[self.user]
        )
    def setUp(self):
        super(TestContractTransition, self).setUp()
        self.stage1 = StageFactory.build(name="stage 1")
        self.stage2 = StageFactory.build(name="stage 2")
        self.stage3 = StageFactory.build(name="stage 3")

        self.flow1 = FlowFactory.build(flow_name="flow 1", stage_order=[self.stage1.id, self.stage2.id, self.stage3.id])
        self.flow2 = FlowFactory.build(flow_name="flow 2", stage_order=[self.stage1.id, self.stage2.id, self.stage3.id])

        self.user = UserFactory.build()

        self.active_contract.flow = self.flow1
コード例 #10
0
    def setUp(self):
        super(TestContractRenewals, self).setUp()
        self.user1 = UserFactory.build(email='user1')

        self.child_contract = ContractBaseFactory.build(
            expiration_date=datetime.date.today() + datetime.timedelta(1),
            is_archived=False, description='child'
        )

        self.child_contract2 = ContractBaseFactory.build(
            expiration_date=datetime.date.today() + datetime.timedelta(1),
            is_archived=False, parent_id=self.active_contract.id, description='child2'
        )

        self.active_contract.followers = [self.user1]
        self.active_contract.children.append(self.child_contract)
コード例 #11
0
    def setUp(self):
        super(TestScoutJobs, self).setUp()
        self.user = UserFactory.create()
        ContractBaseFactory.create(expiration_date=datetime.date.today() +
                                   datetime.timedelta(30),
                                   description='foobar',
                                   followers=[self.user])

        ContractBaseFactory.create(expiration_date=datetime.date.today(),
                                   description='qux',
                                   followers=[self.user])

        ContractBaseFactory.create(expiration_date=datetime.date.today() +
                                   datetime.timedelta(1),
                                   description='qux',
                                   followers=[self.user])
コード例 #12
0
    def setUp(self):
        super(TestContractTransition, self).setUp()
        self.stage1 = StageFactory.build(name='stage 1')
        self.stage2 = StageFactory.build(name='stage 2')
        self.stage3 = StageFactory.build(name='stage 3')

        self.flow1 = FlowFactory.build(
            flow_name='flow 1',
            stage_order=[self.stage1.id, self.stage2.id, self.stage3.id])
        self.flow2 = FlowFactory.build(
            flow_name='flow 2',
            stage_order=[self.stage1.id, self.stage2.id, self.stage3.id])

        self.user = UserFactory.build()

        self.active_contract.flow = self.flow1
コード例 #13
0
    def setUp(self):
        super(TestContractRenewals, self).setUp()
        self.user1 = UserFactory.build(email='user1')

        self.child_contract = ContractBaseFactory.build(
            expiration_date=datetime.date.today() + datetime.timedelta(1),
            is_archived=False,
            description='child')

        self.child_contract2 = ContractBaseFactory.build(
            expiration_date=datetime.date.today() + datetime.timedelta(1),
            is_archived=False,
            parent_id=self.active_contract.id,
            description='child2')

        self.active_contract.followers = [self.user1]
        self.active_contract.children.append(self.child_contract)
コード例 #14
0
 def setUp(self):
     super(TestContractFollows, self).setUp()
     self.user1 = UserFactory.build(email='user1')
     self.user2 = UserFactory.build(email='user2')
     self.active_contract.followers = [self.user1]
コード例 #15
0
def create_a_user(email='*****@*****.**', department='Other', role=None):
    return UserFactory(email=email,
                       first_name='foo',
                       last_name='foo',
                       department=DepartmentFactory.create(name=department),
                       role=role)
コード例 #16
0
 def setUp(self):
     super(TestContractFollows, self).setUp()
     self.user1 = UserFactory.build(email='user1')
     self.user2 = UserFactory.build(email='user2')
     self.active_contract.followers = [self.user1]