Exemple #1
0
def test_max_length_invalid():
    # Given
    max_length_0_validator = validators.max_length(10)

    # When, then raises
    with pytest.raises(validators.Invalid):
        max_length_0_validator('a' * 11)
Exemple #2
0
class User(Document):
    __collection__ = 'users'

    structure = {
        'customer_id': unicode,
        'username': unicode,
        'password': unicode,
        'password_transaction': unicode,
        'email': unicode,
        'fullname': unicode,
        'telephone': unicode,
        'p_node': unicode,
        'p_binary': unicode,
        'left': unicode,
        'right': unicode,
        'level': int,
        'level_dh': int,
        'creation': datetime.datetime,
        'total_pd_left': float,
        'total_pd_right': float,
        'max_out': float,
        'total_earn': float,
        'total_invest': float,
        'total_node': float,
        'status': int,
        'code_active': unicode,
        'total_max_out': float,
        'investment': float,
        'active_email': int,
        'birthday': datetime.datetime,
        'balance_wallet': float,
        'total_receive': float,
        'total_pd_lefts': float,
        'total_pd_rights': float,
        'th_wallet': float,
        'dh_wallet': float,
        'n_wallet': float,
        'ch_wallet': float,
        'address': unicode,
        'cmnd': unicode,
        'account_horder': unicode,
        'account_number': unicode,
        'bankname': unicode,
        'brandname': unicode
    }
    validators = {'email': validators.max_length(120)}
    default_values = {
        'creation': datetime.datetime.utcnow(),
        'level': 0,
        'status': 0,
        'total_pd_left': 0,
        'total_pd_right': 0,
        'total_receive': 0,
        'total_pd_lefts': 0,
        'total_pd_rights': 0,
        'th_wallet': 0,
        'dh_wallet': 0,
        'n_wallet': 0,
        'ch_wallet': 0,
        'balance_wallet': 0
    }
    use_dot_notation = True

    def __repr__(self):
        return '<User %r>' % self.email

    # Flask-Login integration
    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self._id

    def get_role(self):
        return self.role

    def get_user_home(self):
        role = db['roles'].find_one({'_id': self.get_role()})
        return role['home_page']
Exemple #3
0
class User(Document):
    __collection__ = 'users'

    structure = {
        'customer_id' : unicode,
        'email': unicode,
        'code_active': unicode,
        'username': unicode,
        'password': unicode,
        'creation': datetime.datetime,
        'p_binary' : unicode,
        'left' : unicode,
        'right' : unicode,
        'telephone' : float,
        'p_node' : unicode,
        'password_transaction' : unicode,
        'btc_address' : unicode,
        'eth_address' : unicode,
        'ltc_address' : unicode,
        'bch_address' : unicode,
        'usdt_address' : unicode,
        'level' : int,
        'level_global' : int,
        'password_custom' : unicode,
        'total_pd_left' : float,
        'total_pd_right' : float,
        'total_amount_left' : float,
        'total_amount_right': float,
        'm_wallet' : float,
        'r_wallet' : float,
        's_wallet' : float,
        'd_wallet' : float,
        'g_wallet' : float,
        'global_wallet' : float,
        'coin_wallet' : float,
        'balance_wallet' : float,
        'status_authen' : int,
        'authentication' : unicode,
        'max_out' : float,
        'total_max_out' : float,
        'total_earn' : float,
        'position' : unicode,
        'country' : unicode,
        'total_invest' : float,
        'status':int,
        'type': int,
        'active_email': int,
        'secret_2fa': unicode,
        'status_2fa': int,
        'status_withdraw' : int,
        'max_daily': float,
        'investment': float,
        'total_node' : float,
        'max_out_day' : float,
        'max_out_package' : float,
        'status_verify': int,
        'f1earnings_wallet' : float,
        'personal_info': {
            'firstname' : unicode,
            'lastname' : unicode,
            'date_birthday' :unicode,
            'address' :unicode,
            'postalcode' : unicode,
            'city' : unicode,
            'country' : unicode,
            'img_passport_fontside' : unicode,
            'img_passport_backside' : unicode,
            'img_address' : unicode
        }
    }
    validators = {
        'email': validators.max_length(120)
    }
    default_values = {
        'creation': datetime.datetime.utcnow(),
        'm_wallet' : 0,
        'r_wallet' : 0,
        's_wallet' : 0,
        'max_out' : 0,
        'total_earn' : 0,
        'level_global' : 0,
        'total_pd_left' : 0,
        'total_pd_right' : 0,
        'total_amount_left' : 0,
        'total_amount_right' : 0,
        'level' : 0,
        'status_authen' : 0,
        'authentication' : '',
        'left' : '',
        'right' : '',
        'p_binary' : '',
        'type': 0,
        'balance_wallet' : 0,
        'active_email' : 0,
        'code_active' : '',
        'investment' : 0,
        'coin_wallet' : 0,
        'total_node' : 0,
        'max_out_day' : 0,
        'max_out_package' : 0,
        'status_verify' : 0,
        'f1earnings_wallet' : 0

        }
    use_dot_notation = True

    def __repr__(self):
        return '<User %r>' % self.name

    # Flask-Login integration
    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self._id

    def get_role(self):
        return self.role

    def get_user_home(self):
        role = db['roles'].find_one({'_id': self.get_role()})
        return role['home_page']
Exemple #4
0
class User(Document):
    __collection__ = 'users'

    structure = {
        'name': unicode,
        'customer_id': unicode,
        'email': unicode,
        'username': unicode,
        'password': unicode,
        'creation': datetime.datetime,
        'p_binary': unicode,
        'left': unicode,
        'right': unicode,
        'level_thuongthem': float,
        'telephone': float,
        'p_node': unicode,
        'password_transaction': unicode,
        'cmnd': unicode,
        'birthday': unicode,
        'account_horder': unicode,
        'account_number': unicode,
        'bankname': unicode,
        'brandname': unicode,
        'level': int,
        'password_custom': unicode,
        'total_left': float,
        'total_right': float,
        'count_left': float,
        'count_right': float,
        'count_lefts': float,
        'count_rights': float,
        'count_leftss': float,
        'count_rightss': float,
        'm_wallet': float,
        'r_wallet': float,
        's_wallet': float,
        't_wallet': float,
        'g_wallet': float,
        'daily_wallet': float,
        'cancap_wallet': float,
        'tructiep_wallet': float,
        'thunhapf1_wallet': float,
        'thuetncn_wallet': float,
        'tichluy_wallet': float,
        'status_authen': int,
        'authentication': unicode,
        'total_receive': float,
        'position': unicode,
        'country': unicode,
        'total_invest': float,
        'roi': float,
        'max_binary': float,
        'code_active': unicode,
        'address': unicode,
        'status': int,
        'status_re': int,
        'type': int,
        'total_commission': float,
        'secret_2fa': unicode,
        'status_2fa': int,
        'status_withdraw': int,
        'max_daily': float,
        'current_max_daily': float,
        's_left': float,
        's_right': float,
        's_p_node': float,
        's_p_binary': float,
        's_token': float,
        'total_node': float,
        'active': int,
        'package': float,
        'cophieu': float
    }
    validators = {
        'name': validators.max_length(50),
        'email': validators.max_length(120)
    }
    default_values = {
        'creation': datetime.datetime.utcnow(),
        'm_wallet': 0,
        'r_wallet': 0,
        's_wallet': 0,
        't_wallet': 0,
        'g_wallet': 0,
        'level_thuongthem': 0,
        'total_receive': 0,
        'total_left': 0,
        'total_right': 0,
        'count_left': 0,
        'count_rights': 0,
        'count_lefts': 0,
        'count_right': 0,
        'count_rightss': 0,
        'count_leftss': 0,
        'level': 0,
        'status_authen': 0,
        'active': 0,
        'thunhapf1_wallet': 0,
        'authentication': '',
        'left': '',
        'right': '',
        'p_binary': '',
        'type': 0,
        'status_re': 0,
        'total_node': 0,
        'daily_wallet': 0,
        'cancap_wallet': 0,
        'tructiep_wallet': 0,
        'thuetncn_wallet': 0,
        'tichluy_wallet': 0,
        'package': 0,
        'cophieu': 0
    }
    use_dot_notation = True

    def __repr__(self):
        return '<User %r>' % self.name

    # Flask-Login integration
    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self._id

    def get_role(self):
        return self.role

    def get_user_home(self):
        role = db['roles'].find_one({'_id': self.get_role()})
        return role['home_page']
Exemple #5
0
class User(Document):
    __collection__ = 'users'

    structure = {
        'customer_id' : unicode,
        'email': unicode,
        'code_active': unicode,
        'username': unicode,
        'password': unicode,
        'creation': datetime.datetime,
        'p_binary' : unicode,
        'left' : unicode,
        'right' : unicode,
        'telephone' : float,
        'league' : int,
        'p_node' : unicode,
        'password_transaction' : unicode,
        'level' : int,
        'password_custom' : unicode,
        'total_pd_left' : float,
        'total_pd_right' : float,
        'total_amount_left' : float,
        'total_amount_right': float,
        'm_wallet' : float,
        'r_wallet' : float,
        's_wallet' : float,
        'd_wallet' : float,
        'l_wallet' : float,
        'ss_wallet' : float,
       
        'total_earn' : float,
        
        'investment': float,
        'total_node' : float,
        'status' : int,
        'balance' : {
            'bitcoin' : {
                'cryptoaddress' : unicode,
                'available' : float
            },
            'ethereum' : {
                'cryptoaddress' : unicode,
                'available' : float
            },
            'litecoin' : {
                'cryptoaddress' : unicode,
                'available' : float
            },
            'dash' : {
                'cryptoaddress' : unicode,
                'available' : float
            },
            'ripple' : {
                'cryptoaddress' : unicode,
                'available' : float
            },
            'eos' : {
                'cryptoaddress' : unicode,
                'available' : float
            },
            'tether' : {
                'cryptoaddress' : unicode,
                'available' : float
            },
            'coin' : {
                'cryptoaddress' : unicode,
                'available' : float
            }
        },
        'security' : {
            'code_forgot' : unicode,
            'email' : {
                'code' : unicode,
                'status' : int
            },
            'authenticator' : {
                'code' : unicode,
                'status' : int
            },
            'withdraw' : {
                'code' : unicode,
                'status' : int
            },
            'exchange' : {
                'code' : unicode,
                'status' : int
            },
            'lock_account' : {
                'code' : unicode,
                'status' : int
            },
            'login' : {
                'code' : unicode,
                'status' : int
            },
            'fingerprint' : {
                'code' : unicode,
                'status' : int
            },
            'verifyaccount' : {
                'code' : unicode,
                'status' : int
            },
            'count_send_mail' : int
        },
        'personal_info': {
            'firstname' : unicode,
            'lastname' : unicode,
            'date_birthday' :unicode,
            'address' :unicode,
            'postalcode' : unicode,
            'city' : unicode,
            'country' : unicode,
            'img_passport_fontside' : unicode,
            'img_passport_backside' : unicode,
            'img_address' : unicode,
            'img_profile' : unicode,
            'country' :  unicode
        }
    }
    validators = {
        'email': validators.max_length(120)
    }
    default_values = {
        'creation': datetime.datetime.utcnow(),
        'm_wallet' : 0,
        'r_wallet' : 0,
        's_wallet' : 0,
        
        'total_earn' : 0,
        'total_pd_left' : 0,
        'total_pd_right' : 0,
        'total_amount_left' : 0,
        'total_amount_right' : 0,
        'level' : 0,
        'status' : 0,
        'left' : '',
        'right' : '',
        'p_binary' : '',
        
        'investment' : 0,
        
        'total_node' : 0,
        

        }
    use_dot_notation = True

    def __repr__(self):
        return '<User %r>' % self.name

    # Flask-Login integration
    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self._id

    def get_role(self):
        return self.role

    def get_user_home(self):
        role = db['roles'].find_one({'_id': self.get_role()})
        return role['home_page']
Exemple #6
0
 def __init__(self):
     self.schema = {
         'UPRN':
         [mandatory(),
          max_length(13),
          numeric(),
          no_padding_whitespace()],
         'ESTAB_UPRN':
         [mandatory(),
          max_length(13),
          numeric(),
          no_padding_whitespace()],
         'ADDRESS_TYPE': [
             mandatory(),
             in_set({'HH', 'CE', 'SPG'}),
             no_padding_whitespace()
         ],
         'ESTAB_TYPE': [mandatory(), in_set(self.ESTAB_TYPES)],
         'ADDRESS_LEVEL':
         [mandatory(),
          in_set({'E', 'U'}),
          no_padding_whitespace()],
         'ABP_CODE': [
             mandatory(),
             max_length(6),
             no_padding_whitespace(),
             no_pipe_character()
         ],
         'ORGANISATION_NAME':
         [max_length(60),
          no_padding_whitespace(),
          no_pipe_character()],
         'ADDRESS_LINE1': [
             mandatory(),
             max_length(60),
             no_padding_whitespace(),
             no_pipe_character()
         ],
         'ADDRESS_LINE2':
         [max_length(60),
          no_padding_whitespace(),
          no_pipe_character()],
         'ADDRESS_LINE3':
         [max_length(60),
          no_padding_whitespace(),
          no_pipe_character()],
         'TOWN_NAME': [
             mandatory(),
             max_length(30),
             no_padding_whitespace(),
             no_pipe_character()
         ],
         'POSTCODE': [
             mandatory(),
             max_length(8),
             no_padding_whitespace(),
             alphanumeric_postcode(),
             no_pipe_character()
         ],
         'LATITUDE': [
             mandatory(),
             latitude_longitude(max_scale=7, max_precision=9),
             no_padding_whitespace(),
             no_pipe_character(),
             latitude_longitude_range()
         ],
         'LONGITUDE': [
             mandatory(),
             latitude_longitude(max_scale=7, max_precision=8),
             no_padding_whitespace(),
             no_pipe_character(),
             latitude_longitude_range()
         ],
         'OA': [
             mandatory(),
             max_length(9),
             no_padding_whitespace(),
             no_pipe_character()
         ],
         'LSOA': [
             mandatory(),
             max_length(9),
             no_padding_whitespace(),
             no_pipe_character()
         ],
         'MSOA': [
             mandatory(),
             max_length(9),
             no_padding_whitespace(),
             no_pipe_character()
         ],
         'LAD': [
             mandatory(),
             max_length(9),
             no_padding_whitespace(),
             no_pipe_character()
         ],
         'REGION': [
             mandatory(),
             max_length(9),
             no_padding_whitespace(),
             region_matches_treatment_code(),
             no_pipe_character()
         ],
         'HTC_WILLINGNESS':
         [mandatory(), in_set({'0', '1', '2', '3', '4', '5'})],
         'HTC_DIGITAL':
         [mandatory(), in_set({'0', '1', '2', '3', '4', '5'})],
         'FIELDCOORDINATOR_ID': [
             mandatory(),
             max_length(10),
             no_padding_whitespace(),
             no_pipe_character(),
             alphanumeric_plus_hyphen_field_values()
         ],
         'FIELDOFFICER_ID': [
             mandatory(),
             max_length(13),
             no_padding_whitespace(),
             no_pipe_character(),
             alphanumeric_plus_hyphen_field_values()
         ],
         'TREATMENT_CODE': [mandatory(),
                            in_set(self.TREATMENT_CODES)],
         'CE_EXPECTED_CAPACITY': [
             numeric(),
             max_length(4),
             no_padding_whitespace(),
             ce_u_has_expected_capacity(),
             ce_e_has_expected_capacity()
         ],
         'CE_SECURE':
         [mandatory(),
          in_set({'0', '1'}),
          no_padding_whitespace()],
         'PRINT_BATCH': [numeric(),
                         max_length(2),
                         no_padding_whitespace()]
     }
Exemple #7
0
class User(Document):
    __collection__ = 'users'

    structure = {
        'name': unicode,
        'ico_max': float,
        'customer_id': unicode,
        'email': unicode,
        'username': unicode,
        'password': unicode,
        'role': int,
        'creation': datetime.datetime,
        'p_binary': unicode,
        'left': unicode,
        'right': unicode,
        'telephone': float,
        'p_node': unicode,
        'password_transaction': unicode,
        'btc_wallet': unicode,
        'level': int,
        'password_custom': unicode,
        'img_profile': unicode,
        'input_wallet': unicode,
        'total_team': float,
        'total_amount_team': float,
        'm_wallet': float,
        'r_wallet': float,
        's_wallet': float,
        'status_authen': int,
        'authentication': unicode,
        'token_ico': float,
        'max_out': float,
        'total_max_out': float,
        'total_earn': float,
        'position': unicode,
        'country': unicode,
        'total_invest': float,
        'roi': float,
        'max_binary': float,
        'code_active': unicode,
        'status': int,
        'type': int,
        'sva_balance': float,
        'sva_address': unicode,
        'btc_balance': float,
        'btc_address': unicode,
        'usd_balance': float,
        'total_capital_back': float,
        'total_commission': float,
        'secret_2fa': unicode,
        'status_2fa': int,
        'max_daily': float,
        'current_max_daily': float,
        'sva_usd_cms': float,
        'sva_static_interest': float,
        'sva_monthly_bonus': float,
        'sva_sharing_bonus': float,
        'sva_direct_cms': float,
        'sva_enterprise_cms': float,
        'ranking': float,
        'total_f1': float,
        'ltc_address': unicode,
        'ltc_balance': float,
        'sva_usdsva': float,
        'btc_direct_commission': float
    }
    validators = {
        'name': validators.max_length(50),
        'email': validators.max_length(120)
    }
    default_values = {
        'creation': datetime.datetime.utcnow(),
        'm_wallet': 0,
        'r_wallet': 0,
        's_wallet': 0,
        'max_out': 0,
        'total_earn': 0,
        'level': 0,
        'token_ico': 0,
        'status_authen': 0,
        'authentication': '',
        'left': '',
        'right': '',
        'p_binary': '',
        'type': 0
    }
    use_dot_notation = True

    # Flask-Login integration
    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self._id

    def get_role(self):
        return self.role

    def get_user_home(self):
        role = db['roles'].find_one({'_id': self.get_role()})
        return role['home_page']
Exemple #8
0
def test_max_length_valid():
    # Given
    max_length_validator = validators.max_length(10)

    # When
    max_length_validator('a' * 9)