def setUp(self): super(TestProposalAnalytics, self).setUp() self.proposal = ProposalFactory() self.user1 = str(uuid.uuid4()) self.user2 = str(uuid.uuid4()) self.shared1 = SharedProposalFactory(proposal_id=self.proposal.id) self.shared2 = SharedProposalFactory(proposal_id=self.proposal.id) self.start = datetime.utcnow() def get_future(seconds): return self.start + timedelta(seconds=seconds) EventFactory(shared_proposal=self.shared1, kind="load", user_uid=self.user1, created_at=self.start) EventFactory(shared_proposal=self.shared1, kind="ping", user_uid=self.user1, created_at=get_future(15), data={}) EventFactory(shared_proposal=self.shared1, kind="ping", user_uid=self.user1, created_at=get_future(30), data={}) EventFactory(shared_proposal=self.shared1, kind="load", user_uid=self.user1, created_at=get_future(500)) EventFactory(shared_proposal=self.shared1, kind="ping", user_uid=self.user1, created_at=get_future(555), data={}) EventFactory(shared_proposal=self.shared1, kind="load", user_uid=self.user2, created_at=get_future(10)) EventFactory(shared_proposal=self.shared1, kind="ping", user_uid=self.user2, created_at=get_future(50), data={}) EventFactory(shared_proposal=self.shared1, kind="outbound_click", user_uid=self.user2, data={"url": "proppy.io"}) EventFactory(shared_proposal=self.shared1, kind="outbound_click", user_uid=self.user1, data={"url": "google.io"}) EventFactory(shared_proposal=self.shared1, kind="outbound_click", user_uid=self.user1, data={"url": "proppy.io"}) EventFactory(shared_proposal=self.shared2, kind="load", user_uid=self.user1, created_at=self.start) EventFactory(shared_proposal=self.shared2, kind="load", user_uid=self.user2, created_at=get_future(10)) EventFactory(shared_proposal=self.shared2, kind="ping", user_uid=self.user2, created_at=get_future(25), data={}) EventFactory(shared_proposal=self.shared2, kind="outbound_click", user_uid=self.user1, data={"url": "google.io"})
def setUp(self): super(TestTemplates, self).setUp() self.user = UserFactory() self.waw = CompanyFactory() # share_uid needs to be one from dashboard/views list self.template = ProposalFactory( title="Template", share_uid="LQROVRA4Y", company=self.waw )
def test_cannot_duplicate_any_random_shared_proposal(self): proposal = ProposalFactory(company=self.waw) self.shared = SharedProposalFactory(proposal=proposal) _, status = self.post_json( "/templates/{}/duplicate".format(proposal.share_uid), {}, user=self.user ) self.assertEqual(status, 404)
def test_can_share_draft_if_at_limit_for_plan(self): self.user.company.created_at = datetime.utcnow() - timedelta(days=60) ChargebeeSubscriptionCacheFactory(company=self.user.company) # Creating 4 sent proposals for _ in range(0, 4): SharedProposalFactory( version=1, proposal=ProposalFactory(company=self.user.company, status="sent")) _, status = self.post_json(self.url, {}, user=self.user) self.assertEqual(status, 200)
def setUp(self): super(TestSharing, self).setUp() self.user = UserFactory() self.c = ClientFactory(company=self.user.company) self.p = ProposalFactory(company=self.user.company, client=self.c) self.url = "/proposals/{}/share".format(self.p.id) self.email_url = "/proposals/{}/share-email".format(self.p.id) self.sent_url = "/proposals/{}/mark-as-sent".format(self.p.id) self.email = { "emails": ["*****@*****.**", "*****@*****.**"], "from": "Me", "subject": "Hello", "body": "Yolo %s" % self.p.share_uid, }
def test_access_proposal_not_shared(self): p = ProposalFactory(company=self.user.company) _, status = self.get_json("/shared/{}".format(p.share_uid)) self.assertEqual(status, 404)
def setUp(self): super(TestAccessSharedProposal, self).setUp() self.user = UserFactory() self.p = ProposalFactory(company=self.user.company) self.shared = SharedProposalFactory(proposal=self.p) self.url = "/shared/{}".format(self.p.share_uid)
def setUp(self): super(TestProposal, self).setUp() self.proposal = ProposalFactory() self.section_uid = str(uuid.uuid4()) self.subsection_uid = str(uuid.uuid4()) self.last_subsection_uid = str(uuid.uuid4()) self.proposal.blocks.extend([ Block(BlockType.Paragraph.value, None, data={'value': 'Welcome'}, ordering=0), Block(BlockType.Section.value, None, data={'value': 'Introduction'}, ordering=1, uid=self.section_uid), Block(BlockType.Paragraph.value, None, data={'value': 'My name is'}, ordering=2), Block(BlockType.Subtitle.value, None, data={'value': 'Previous word'}, ordering=3), Block(BlockType.UnorderedItem.value, None, data={'value': 'first'}, ordering=4), Block(BlockType.OrderedItem.value, None, data={'value': 'second'}, ordering=5), Block(BlockType.Section.value, None, data={'value': 'Scope'}, ordering=6), Block(BlockType.UnorderedItem.value, None, data={'value': 'ul'}, ordering=7), Block(BlockType.Subtitle.value, None, data={'value': 'Design'}, ordering=8, uid=self.subsection_uid), Block(BlockType.Paragraph.value, None, data={'value': 'Mac'}, ordering=9), Block(BlockType.Paragraph.value, None, data={'value': ''}, ordering=10), Block(BlockType.Subtitle.value, None, data={'value': 'Dev'}, ordering=11, uid=self.last_subsection_uid), Block(BlockType.Signature.value, None, data={'name': 'Bob'}, ordering=12), ])
class TestProposal(DatabaseTest): def setUp(self): super(TestProposal, self).setUp() self.proposal = ProposalFactory() self.section_uid = str(uuid.uuid4()) self.subsection_uid = str(uuid.uuid4()) self.last_subsection_uid = str(uuid.uuid4()) self.proposal.blocks.extend([ Block(BlockType.Paragraph.value, None, data={'value': 'Welcome'}, ordering=0), Block(BlockType.Section.value, None, data={'value': 'Introduction'}, ordering=1, uid=self.section_uid), Block(BlockType.Paragraph.value, None, data={'value': 'My name is'}, ordering=2), Block(BlockType.Subtitle.value, None, data={'value': 'Previous word'}, ordering=3), Block(BlockType.UnorderedItem.value, None, data={'value': 'first'}, ordering=4), Block(BlockType.OrderedItem.value, None, data={'value': 'second'}, ordering=5), Block(BlockType.Section.value, None, data={'value': 'Scope'}, ordering=6), Block(BlockType.UnorderedItem.value, None, data={'value': 'ul'}, ordering=7), Block(BlockType.Subtitle.value, None, data={'value': 'Design'}, ordering=8, uid=self.subsection_uid), Block(BlockType.Paragraph.value, None, data={'value': 'Mac'}, ordering=9), Block(BlockType.Paragraph.value, None, data={'value': ''}, ordering=10), Block(BlockType.Subtitle.value, None, data={'value': 'Dev'}, ordering=11, uid=self.last_subsection_uid), Block(BlockType.Signature.value, None, data={'name': 'Bob'}, ordering=12), ]) def test_can_extract_search_content(self): search_content = self.proposal.extract_search_content() self.assertEqual(len(search_content), 5) self.assertEqual(search_content[0][1], "h1") self.assertEqual(search_content[0][2], "Introduction") self.assertEqual(search_content[0][3], "My name is Previous word first second") self.assertEqual(search_content[1][1], "h1") self.assertEqual(search_content[1][2], "Scope") self.assertEqual(search_content[1][3], "ul Design Mac Dev") self.assertEqual(search_content[2][1], "h2") self.assertEqual(search_content[2][2], "Previous word") self.assertEqual(search_content[2][3], "first second") self.assertEqual(search_content[3][1], "h2") self.assertEqual(search_content[3][2], "Design") self.assertEqual(search_content[3][3], "Mac ") self.assertEqual(search_content[4][1], "h2") self.assertEqual(search_content[4][2], "Dev") def test_get_import_section_blocks_h1(self): blocks = self.proposal.get_import_section_blocks(self.section_uid) self.assertEqual(len(blocks), 5) def test_get_import_section_blocks_h2(self): blocks = self.proposal.get_import_section_blocks(self.subsection_uid) self.assertEqual(len(blocks), 3) def test_importing_doesnt_remove_old_blocks(self): blocks = self.proposal.get_import_section_blocks(self.subsection_uid) self.assertNotEqual(blocks[0].uid, self.subsection_uid) def test_signature_block_gets_emptied(self): blocks = self.proposal.get_import_section_blocks( self.last_subsection_uid) self.assertFalse("name" in blocks[-1].data)