def test_reserved_words(): def foo(id_: str): pass args = ff.build_argument_list({'id': 'bar'}, foo) assert 'id_' in args and args['id_'] == 'bar'
def create(cls, **kwargs): if 'email' in kwargs: kwargs['email'] = str(kwargs['email']).lower() try: kwargs['salt'] = bcrypt.gensalt() kwargs['password_hash'] = User._hash_password(kwargs['password'], kwargs['salt']) except KeyError: raise ff.MissingArgument('password is a required field for User::create()') return cls(**ff.build_argument_list(kwargs, cls))
def test_optional_datetimes(): class TestAppService(ff.ApplicationService): def __call__(self, last_updated: datetime = None, start_date: datetime = None, **kwargs): pass sut = TestAppService() x = ff.build_argument_list({'last_updated': '2021-05-26T06:20:15'}, sut) assert isinstance(x['last_updated'], datetime) is True
def add_contact(self, contact: domain.Contact, **kwargs): if self.get_member_by_contact_id(contact.id) is None: kwargs.update({'contact': contact}) self.members.append( domain.AudienceMember( **ff.build_argument_list(kwargs, domain.AudienceMember)))