Exemplo n.º 1
0
 def test_user_serialize(self):
     user_schema = UserSchema(many=True)
     users = UserActions.find_all()
     user_result = user_schema.dump(users)
     user_result_json = json.dumps(user_result.data)
     user_expected_json = '[{"id": 118600698523151, "name": "Luke Skywalker Alaaaiffajfch Occhinosky",' \
                          ' "profile_url": "", "birthday": "1980-01-30"}, {"id": 118600698523152, "name": ' \
                          '"Han Solo Alaaaiffajfch Occhinosky", "profile_url": "", "birthday": "1979-01-30"}, ' \
                          '{"id": 118600698523153, "name": "Padme  Alaaaiffajfch Occhinosky", ' \
                          '"profile_url": "", "birthday": "1979-01-30"}]'
     self.assertEqual(user_expected_json, user_result_json)
     pass
Exemplo n.º 2
0
    def run(self):
        print("Add posts to facebook profile")
        directory = os.path.dirname(os.path.realpath(__file__))
        file = open(directory + '/posts.txt', 'r')
        posts = file.readlines()

        for user in UserActions.find_all():
            if user.access_token is not "":
                graph = GraphAPI(user.access_token)
                for post in posts:
                    print(graph.put_object("me", "feed", message=post))

        pass
Exemplo n.º 3
0
    def test_user_serializer(self):
        users = UserActions.find_all()
        serializer = Serializer("User", users)

        # @todo assert an ordered dictionary instead
        user_result_json = json.dumps(serializer.run())
        user_expected_json = '[{"id": 118600698523151, "name": "Luke Skywalker Alaaaiffajfch Occhinosky",' \
                             ' "profile_url": "", "birthday": "1980-01-30"}, {"id": 118600698523152, "name": ' \
                             '"Han Solo Alaaaiffajfch Occhinosky", "profile_url": "", "birthday": "1979-01-30"}, ' \
                             '{"id": 118600698523153, "name": "Padme  Alaaaiffajfch Occhinosky", ' \
                             '"profile_url": "", "birthday": "1979-01-30"}]'

        self.assertEqual(user_expected_json, user_result_json)
Exemplo n.º 4
0
def load_fixtures():
    pprint.pprint("Load fixtures -----------------")
    dir = os.path.dirname(os.path.realpath(__file__))
    file = open(dir + '/posts.txt', 'r')
    posts = file.readlines()
    # pprint.pprint(posts)

    users = UserActions.find_all()

    for user in users:
        if user.access_token is not "":
            graph = GraphAPI(user.access_token)
            for post in posts:
                graph.put_object("me", "feed", message=post)

    pprint.pprint("Total user: " + str(len(users)))
Exemplo n.º 5
0
def load_fixtures():
    pprint.pprint("Load fixtures -----------------")
    dir = os.path.dirname(os.path.realpath(__file__))
    file = open(dir + '/posts.txt', 'r')
    posts = file.readlines()
    # pprint.pprint(posts)

    users = UserActions.find_all()

    for user in users:
        if user.access_token is not "":
            graph = GraphAPI(user.access_token)
            for post in posts:
                graph.put_object("me", "feed", message=post)


    pprint.pprint("Total user: " + str(len(users)))