Esempio n. 1
0
 def test_delete_movie(self):
     g = graph.graph()
     g.load_data(test_data_path)
     g.delete_movie('movie1')
     self.assertTrue(len(g.all_actors) == 3)
     self.assertTrue(len(g.all_movies) == 4)
     return
Esempio n. 2
0
 def test_delete_actor(self):
     g = graph.graph()
     g.load_data(test_data_path)
     g.delete_actor('actor1')
     self.assertTrue(len(g.all_actors) == 2)
     self.assertTrue(len(g.all_movies) == 5)
     return
Esempio n. 3
0
 def test_add_actor(self):
     g = graph.graph()
     g.load_data(test_data_path)
     actor = {
         "json_class": "Actor",
         "name": "new actor",
         "age": 12,
         "total_gross": 7,
         "movies": ["movie2"
                    "new movie"]
     }
     g.add_actor(actor)
     self.assertTrue(len(g.all_actors) == 4)
     self.assertTrue(len(g.all_movies) == 6)
     return
Esempio n. 4
0
 def test_add_movie(self):
     g2 = graph.graph()
     film = {
         "json_class":
         "Movie",
         "name":
         "Live Free or Die Hard",
         "wiki_page":
         "https://en.wikipedia.org/wiki/Live_Free_or_Die_Hard",
         "box_office":
         383,
         "year":
         0,
         "actors": [
             "Bruce Willis", "Justin Long", "Timothy Olyphant",
             "Mary Elizabeth Winstead", "Maggie Q", "Kevin Smith"
         ]
     }
     g2.add_movie(film)
     self.assertTrue(len(g2.all_movies) == 1)
     return
Esempio n. 5
0
'''
Reference: http://flask.pocoo.org/docs/1.0/tutorial/
'''
import os
from flask import Flask, render_template, session
from flaskr import graph

root = ""
g = graph.graph()


from flaskr import actors, movies, analysis

def create_app(test_config=None):
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(
        SECRET_KEY='dev',
        DATA_PATH='./data/data.json'
    )

    if test_config is None:
        # load the instance config, if it exists, when not testing
        app.config.from_pyfile('config.py', silent=True)
    else:
        # load the test config if passed in
        app.config.from_mapping(test_config)

    # ensure the instance folder exists
    try:
        os.makedirs(app.instance_path)
    except OSError:
Esempio n. 6
0
 def test_most_connection(self):
     g = graph.graph()
     g.load_data(test_data_path)
     g.assign_connection()
     ret = g.get_actor_most_connection()
     self.assertTrue(len(ret) == 3)
Esempio n. 7
0
 def test_connection(self):
     g = graph.graph()
     g.load_data(test_data_path)
     g.assign_connection()
     self.assertTrue(len(g.all_actors['actor1']['connection'].keys()) == 2)
     return
Esempio n. 8
0
 def test_load(self):
     g = graph.graph()
     g.load_data(test_data_path)
     self.assertEqual(len(g.all_movies), 5)
     self.assertEqual(len(g.all_actors), 3)
     return