class TestEncryptedPassportElement: type_ = 'type' data = 'data' phone_number = 'phone_number' email = 'email' files = [PassportFile('file_id', 50, 0)] front_side = PassportFile('file_id', 50, 0) reverse_side = PassportFile('file_id', 50, 0) selfie = PassportFile('file_id', 50, 0) def test_expected_values(self, encrypted_passport_element): assert encrypted_passport_element.type == self.type_ assert encrypted_passport_element.data == self.data assert encrypted_passport_element.phone_number == self.phone_number assert encrypted_passport_element.email == self.email assert encrypted_passport_element.files == self.files assert encrypted_passport_element.front_side == self.front_side assert encrypted_passport_element.reverse_side == self.reverse_side assert encrypted_passport_element.selfie == self.selfie def test_to_dict(self, encrypted_passport_element): encrypted_passport_element_dict = encrypted_passport_element.to_dict() assert isinstance(encrypted_passport_element_dict, dict) assert encrypted_passport_element_dict['type'] == encrypted_passport_element.type assert encrypted_passport_element_dict['data'] == encrypted_passport_element.data assert ( encrypted_passport_element_dict['phone_number'] == encrypted_passport_element.phone_number ) assert encrypted_passport_element_dict['email'] == encrypted_passport_element.email assert isinstance(encrypted_passport_element_dict['files'], list) assert ( encrypted_passport_element_dict['front_side'] == encrypted_passport_element.front_side.to_dict() ) assert ( encrypted_passport_element_dict['reverse_side'] == encrypted_passport_element.reverse_side.to_dict() ) assert ( encrypted_passport_element_dict['selfie'] == encrypted_passport_element.selfie.to_dict() ) def test_equality(self): a = EncryptedPassportElement(self.type_, data=self.data) b = EncryptedPassportElement(self.type_, data=self.data) c = EncryptedPassportElement(self.data, '') d = PassportElementError('source', 'type', 'message') assert a == b assert hash(a) == hash(b) assert a is not b assert a != c assert hash(a) != hash(c) assert a != d assert hash(a) != hash(d)
def passport_file(): return PassportFile( file_id=TestPassportFile.file_id, file_unique_id=TestPassportFile.file_unique_id, file_size=TestPassportFile.file_size, file_date=TestPassportFile.file_date, )
def test_equality(self): a = PassportFile(self.file_id, self.file_unique_id, self.file_size, self.file_date) b = PassportFile("", self.file_unique_id, self.file_size, self.file_date) c = PassportFile(self.file_id, self.file_unique_id, "", "") d = PassportFile("", "", self.file_size, self.file_date) e = PassportElementError("source", "type", "message") assert a == b assert hash(a) == hash(b) assert a is not b assert a == c assert hash(a) == hash(c) assert a != d assert hash(a) != hash(d) assert a != e assert hash(a) != hash(e)
def test_equality(self): a = PassportFile(self.file_id, self.file_unique_id, self.file_size, self.file_date) b = PassportFile('', self.file_unique_id, self.file_size, self.file_date) c = PassportFile(self.file_id, self.file_unique_id, '', '') d = PassportFile('', '', self.file_size, self.file_date) e = PassportElementError('source', 'type', 'message') assert a == b assert hash(a) == hash(b) assert a is not b assert a == c assert hash(a) == hash(c) assert a != d assert hash(a) != hash(d) assert a != e assert hash(a) != hash(e)
class TestEncryptedPassportElement: type_ = "type" hash = "this is a hash" data = "data" phone_number = "phone_number" email = "email" files = [PassportFile("file_id", 50, 0, 25)] front_side = PassportFile("file_id", 50, 0, 25) reverse_side = PassportFile("file_id", 50, 0, 25) selfie = PassportFile("file_id", 50, 0, 25) def test_slot_behaviour(self, encrypted_passport_element, mro_slots): inst = encrypted_passport_element for attr in inst.__slots__: assert getattr(inst, attr, "err") != "err", f"got extra slot '{attr}'" assert len(mro_slots(inst)) == len(set( mro_slots(inst))), "duplicate slot" def test_expected_values(self, encrypted_passport_element): assert encrypted_passport_element.type == self.type_ assert encrypted_passport_element.hash == self.hash assert encrypted_passport_element.data == self.data assert encrypted_passport_element.phone_number == self.phone_number assert encrypted_passport_element.email == self.email assert encrypted_passport_element.files == self.files assert encrypted_passport_element.front_side == self.front_side assert encrypted_passport_element.reverse_side == self.reverse_side assert encrypted_passport_element.selfie == self.selfie def test_to_dict(self, encrypted_passport_element): encrypted_passport_element_dict = encrypted_passport_element.to_dict() assert isinstance(encrypted_passport_element_dict, dict) assert encrypted_passport_element_dict[ "type"] == encrypted_passport_element.type assert encrypted_passport_element_dict[ "data"] == encrypted_passport_element.data assert (encrypted_passport_element_dict["phone_number"] == encrypted_passport_element.phone_number) assert encrypted_passport_element_dict[ "email"] == encrypted_passport_element.email assert isinstance(encrypted_passport_element_dict["files"], list) assert (encrypted_passport_element_dict["front_side"] == encrypted_passport_element.front_side.to_dict()) assert (encrypted_passport_element_dict["reverse_side"] == encrypted_passport_element.reverse_side.to_dict()) assert (encrypted_passport_element_dict["selfie"] == encrypted_passport_element.selfie.to_dict()) def test_equality(self): a = EncryptedPassportElement(self.type_, self.hash, data=self.data) b = EncryptedPassportElement(self.type_, self.hash, data=self.data) c = EncryptedPassportElement(self.data, "") d = PassportElementError("source", "type", "message") assert a == b assert hash(a) == hash(b) assert a is not b assert a != c assert hash(a) != hash(c) assert a != d assert hash(a) != hash(d)
class TestEncryptedPassportElement: type_ = 'type' data = 'data' phone_number = 'phone_number' email = 'email' files = [PassportFile('file_id', 50, 0)] front_side = PassportFile('file_id', 50, 0) reverse_side = PassportFile('file_id', 50, 0) selfie = PassportFile('file_id', 50, 0) def test_slot_behaviour(self, encrypted_passport_element, recwarn, mro_slots): inst = encrypted_passport_element for attr in inst.__slots__: assert getattr(inst, attr, 'err') != 'err', f"got extra slot '{attr}'" assert not inst.__dict__, f"got missing slot(s): {inst.__dict__}" assert len(mro_slots(inst)) == len(set( mro_slots(inst))), "duplicate slot" inst.custom, inst.phone_number = 'should give warning', self.phone_number assert len(recwarn) == 1 and 'custom' in str( recwarn[0].message), recwarn.list def test_expected_values(self, encrypted_passport_element): assert encrypted_passport_element.type == self.type_ assert encrypted_passport_element.data == self.data assert encrypted_passport_element.phone_number == self.phone_number assert encrypted_passport_element.email == self.email assert encrypted_passport_element.files == self.files assert encrypted_passport_element.front_side == self.front_side assert encrypted_passport_element.reverse_side == self.reverse_side assert encrypted_passport_element.selfie == self.selfie def test_to_dict(self, encrypted_passport_element): encrypted_passport_element_dict = encrypted_passport_element.to_dict() assert isinstance(encrypted_passport_element_dict, dict) assert encrypted_passport_element_dict[ 'type'] == encrypted_passport_element.type assert encrypted_passport_element_dict[ 'data'] == encrypted_passport_element.data assert (encrypted_passport_element_dict['phone_number'] == encrypted_passport_element.phone_number) assert encrypted_passport_element_dict[ 'email'] == encrypted_passport_element.email assert isinstance(encrypted_passport_element_dict['files'], list) assert (encrypted_passport_element_dict['front_side'] == encrypted_passport_element.front_side.to_dict()) assert (encrypted_passport_element_dict['reverse_side'] == encrypted_passport_element.reverse_side.to_dict()) assert (encrypted_passport_element_dict['selfie'] == encrypted_passport_element.selfie.to_dict()) def test_equality(self): a = EncryptedPassportElement(self.type_, data=self.data) b = EncryptedPassportElement(self.type_, data=self.data) c = EncryptedPassportElement(self.data, '') d = PassportElementError('source', 'type', 'message') assert a == b assert hash(a) == hash(b) assert a is not b assert a != c assert hash(a) != hash(c) assert a != d assert hash(a) != hash(d)