def test_modify_contact_firstname(app):
    if app.profile.count() == 0:
        app.profile.create(Profile(firstname="test"))
    old_profiles = app.profile.get_contact_list()
    app.profile.modify_first_contact(Profile(firstname="Sfairat"))
    new_profiles = app.profile.get_contact_list()
    assert len(old_profiles) == len(new_profiles)
Esempio n. 2
0
    def post(self, user_id):
        """
        Upload user's profile icon
        """
        uploaded_file = request.files['upload']
        filename = "_".join([user_id, uploaded_file.filename])

        # upload the file to S3 server
        conn = boto.connect_s3(os.environ['S3_KEY'], os.environ['S3_SECRET'])
        bucket = conn.get_bucket('profile-icon')
        key = bucket.new_key(filename)
        key.set_contents_from_file(uploaded_file)

        # update the user's profile document
        profile = Profile.objects(user=user_id).first()
        if profile is None:
            profile = Profile(
                user=user_id,
                profile_icon=
                'https://s3-us-west-2.amazonaws.com/profile-icon/%s' %
                filename)
            profile.save()
        else:
            profile.profile_icon = 'https://s3-us-west-2.amazonaws.com/profile-icon/%s' % filename
            profile.save()

        return serialize(profile)
Esempio n. 3
0
 def get_contact_list(self):
     if self.profile_cache is None:
         wd = self.app.wd
         self.profile_cache = []
         for element in wd.find_elements_by_name("entry"):
             text = element.text
             id = element.find_element_by_name("selected[]").get_attribute("value")
             self.profile_cache.append(Profile(firstname=text, id=id))
     return list(self.profile_cache)
Esempio n. 4
0
 async def profiles(cls):
     administrator = Profile({
         'username': '******',
         'password': '******',
         'email': '*****@*****.**',
         'name': {
             'first': 'administrator'
         }
     })
     await administrator.save()
Esempio n. 5
0
def app(request):
    global fixture
    global target
    if target is None:
        with open(request.config.getoption("--target")) as config_file:
            target = json.load(config_file)
    if fixture is None or not fixture.is_valid(
    ):  #если фикстура не проинициализировалась или невалидна
        fixture = Application()
    fixture.session.ensure_login(
        Profile(mobile=target['mobile'], password=target['password']))
    return fixture
Esempio n. 6
0
    def post(self, user_id):
        """
        Edit the user's profile if the profile exists
        Otherwise, create a new profile document
        """
        args = profileParser.parse_args()
        username = args['username']
        school = args['school']
        intro = args['intro']

        profile = Profile.objects(user=user_id).first()
        if profile is None:
            profile = Profile(user=user_id,
                              username=username,
                              school=school,
                              intro=intro)
            profile.save()
        else:
            profile.username = username
            profile.school = school
            profile.intro = intro
            profile.save()

        return serialize(profile)
 def novo(self, rs):
     return Profile(self.usuario, rs[0], rs[1], rs[2])
def test_add_contact(app):
    old_profiles = app.profile.get_contact_list()
    app.profile.create_contact(Profile(firstname="Saimon", lastname="Ozhereliev", nickname="Sfai", address="Moscow", mobile="916 176-66-66", email="*****@*****.**",
                                       bday="18", bmonth="April", byear="1986", address2="Moscow city"))
    new_profiles = app.profile.get_contact_list()
    assert len(old_profiles) + 1 == len(new_profiles)
def test_add_empty_contact(app):
    old_profiles = app.profile.get_contact_list()
    app.profile.create_contact(Profile(firstname="", lastname="", nickname="", address="", mobile="", email="",
                                       bday="", bmonth="", byear="", address2=""))
    new_profiles = app.profile.get_contact_list()
    assert len(old_profiles) + 1 == len(new_profiles)