Пример #1
0
    def setUp(self):
        super().setUp()
        self.proposal1 = DefaultProposalFactory()
        self.proposal2 = DefaultProposalFactory()

        self.company2 = self.proposal2.company

        self.proposal1.company.users.append(UserFactory())
        self.proposal2.company.users.append(UserFactory())

        self.proposal1.company.clients.append(ClientFactory())
        self.proposal2.company.clients.append(ClientFactory())

        print(self.proposal1.company.users.all())
        print(self.proposal2.company)
Пример #2
0
 def setUp(self):
     super(TestAuth, self).setUp()
     self.user = UserFactory()
     self.user2 = UserFactory()
     self.other_company = self.user2.company
     self.p = DefaultProposalFactory(company=self.other_company,
                                     client=None)
Пример #3
0
    def run(self):
        """
        The data here is as mix of randomized and hardcoded to
        capture a few corner cases (long names etc).
        """
        db = setup.db

        for table in reversed(db.metadata.sorted_tables):
            db.engine.execute(table.delete())

        company = CompanyFactory(name="A Cool Agency")
        user = UserFactory(id=None,
                           company=company,
                           email="*****@*****.**",
                           is_admin=True)
        db.session.add(user)
        db.session.commit()

        # we generate proposals with share uids of the templates so we can test
        # duplication locally
        for i in range(4):
            title = "Proposal for %s" % f.company()
            p = DefaultProposalFactory(company=company,
                                       title=title,
                                       client=None,
                                       share_uid=PROPOSAL_TEMPLATES[i]["uid"])
            db.session.add(p)
            s = SharedProposalFactory(proposal=p, version=1)
            db.session.add(s)

        # Super long title
        p = DefaultProposalFactory(
            company=company,
            title="long " * 12,
            client=None,
        )
        db.session.add(p)

        db.session.commit()
Пример #4
0
 def setUp(self):
     super().setUp()
     self.user = UserFactory()
     self.p = DefaultProposalFactory(company=self.user.company, client=None)
     self.shared = self.p.create_shared([])
     self.url = "/shared/%s/sign" % self.p.share_uid
     self.data = {
         "signature":
         "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA0MAAALoCAYAAAC6bC52",
         "name": "Bob",
         "userAgent": "user-agent"
     }
     self.sig_block = SharedBlock.from_proposal_block(
         Block(BlockType.Signature.value, ordering=10))
Пример #5
0
    def test_cant_import_other_company_section(self):
        p_new = DefaultProposalFactory()
        uid = p_new.blocks.filter_by(type='section').first().uid

        with self.assertRaises(Exception):
            self.p.get_import_section_blocks(uid)

        # Check API level as well.
        data, status_code = self.post_json(
            "/proposals/{}/sections/import".format(self.p.id),
            {"uidToImport": uid},
            user=self.user)

        # We're not cat
        self.assertEqual(status_code, 403)
Пример #6
0
 def setUp(self):
     super(TestProposalUpdate, self).setUp()
     self.user = UserFactory()
     self.p = DefaultProposalFactory(company=self.user.company, client=None)
     self.now = datetime.utcnow().timestamp() + 1000
Пример #7
0
 def setUp(self):
     super(TestSectionImporting, self).setUp()
     self.user = UserFactory()
     self.p1 = DefaultProposalFactory(company=self.user.company)
     self.p2 = DefaultProposalFactory(company=self.user.company)
Пример #8
0
 def setUp(self):
     super(TestProposal, self).setUp()
     self.user = UserFactory()
     self.p = DefaultProposalFactory(company=self.user.company, client=None)
Пример #9
0
 def setUp(self):
     super(SearchIndexingProposal, self).setUp()
     self.proposal1 = DefaultProposalFactory()
     self.proposal2 = DefaultProposalFactory(company=self.proposal1.company)
     self.index = current_app.config["ES_IMPORT_INDEX"]
     self.es_client = get_test_client(delete_index=True)
Пример #10
0
 def setUp(self):
     super().setUp()
     self.user = UserFactory()
     self.p = DefaultProposalFactory(client=None)
     self.sig = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA0MAAALoCAYAAAC6bC52"
Пример #11
0
 def setUp(self):
     super(TestSharedCommenting, self).setUp()
     self.user = UserFactory()
     self.p = DefaultProposalFactory(company=self.user.company)
     self.shared = SharedProposalFactory(proposal=self.p)
     self.url = "/shared/{}/comments".format(self.p.share_uid)