def get_johns_kyc_document(recreate=False): if BaseTestLive._johns_kyc_document is None or recreate: document = Document() document.type = 'IDENTITY_PROOF' document.user_id = BaseTestLive.get_john().id BaseTestLive._johns_kyc_document = Document(**document.save()) return BaseTestLive._johns_kyc_document
def create(self, user): mid = MangoUser.objects.get(user=user).mid self.mid = mid document = Document(user=mid, Type=self.doc_type) document.save() self.did = document.get_pk() self.creation_date = document.CreationDate self.status = 'CREATED' self.save()
def test_GetKycDocuments(self): documents = Document.all() self.assertTrue(documents) result = Document.all(page=1, per_page=2, Sort='CreationDate:ASC') self.assertTrue(result) result2 = Document.all(page=1, per_page=2, Sort='CreationDate:DESC') self.assertTrue(result2) self.assertFalse(result[0].id == result2[0].id)
def test_GetKycDocuments(self): documents = Document.all() self.assertTrue(documents) result = Document.all(page=1, per_page=2, Sort='CreationDate:ASC') self.assertTrue(result) result2 = Document.all(page=1, per_page=2, Sort='CreationDate:DESC') self.assertTrue(result2) self.assertFalse(result.data[0].id == result2.data[0].id)
def create(self, file): document = Document.get(id=self.doc.did) page = Page(user=self.doc.mid, document=document, file=file) page.save() self.paid = page.get_pk() self.save()
def test_GetKycDocument(self): johns_document = BaseTestLive.get_johns_kyc_document() document = Document.get(johns_document.id) self.assertTrue(document) self.assertEqual(document.id, johns_document.id) self.assertEqual(document.status, johns_document.status) self.assertEqual(document.type, johns_document.type)
def validate(self): if self.status is 'CREATED': document = Document.get(id=self.did) document.status = 'VALIDATION_ASKED' document.save() self.status = document.status self.save() else: raise BaseException( 'Cannot ask validation if not in created status')
def validate(self, document_type, front, back): if not self.validation_status == 'VALIDATED': doc = Document(type='IDENTITY_PROOF', user=self.mid) doc.save() with open(front, 'rb') as f: encf = base64.b64decode(f.read()) with open(back, 'rb') as b: encb = base64.b64encode(b.read()) pf = Page(document=doc, file=encf, user=self.mid) pf.save() pb = Page(document=doc, file=encb, user=self.mid) pb.save() doc.status = 'VALIDATION_ASKED' doc.save() print(doc) # see if this validation works or if the last step is necessary. else: return 'Documents have been already validated'
def get_document(self): user = self.mangopay_user.get_mango_user() return Document(id=self.mangopay_id, user=user, type=self.type)
def GetUserKycDocument(self, document_id, user_id): document = Document() document.Id = document_id document.Status = "VALIDATED" return document