Exemple #1
0
 def test_torque_load_csv(self):
     csv_file = "test/test-data/books.csv"
     if os.path.exists("test-data/books.csv"):
         csv_file = "test-data/books.csv"
     g = Graph(graph_name="books5")
     g.load_csv(csv_file, "isbn")
     # print(g.scan())
     actual = g.scan(20, 'e')
     expected = {
         'result': [{
             'id': 'ratings_4'
         }, {
             'id': 'best_book_id'
         }, {
             'id': 'work_text_reviews_count'
         }, {
             'id': 'original_publication_year'
         }, {
             'id': 'average_rating'
         }, {
             'id': 'ratings_1'
         }, {
             'id': 'language_code'
         }, {
             'id': 'image_url'
         }, {
             'id': 'books_count'
         }, {
             'id': 'work_ratings_count'
         }, {
             'id': 'isbn13'
         }, {
             'id': 'title'
         }, {
             'id': 'ratings_5'
         }, {
             'id': 'ratings_3'
         }, {
             'id': 'small_image_url'
         }, {
             'id': 'ratings_count'
         }, {
             'id': 'isbn'
         }, {
             'id': 'book_id'
         }, {
             'id': 'authors'
         }, {
             'id': 'ratings_2'
         }]
     }
     self.assertTrue(actual == expected)
     self.assertTrue(
         ordered(g.v('Kathryn Stockett').inc().out("title").all()) ==
         ordered({'result': [{
             'id': 'The Help'
         }]}))
     g.close()
Exemple #2
0
    def test_torque_load_nq(self):
        nq_file = "test/test-data/100lines.nq"
        if os.path.exists("test-data/100lines.nq"):
            nq_file = "test-data/100lines.nq"
        g = Graph(graph_name="movies3", cog_path_prefix="/tmp/" + DIR_NAME)
        g.load_triples(nq_file, 'movies3')
        res = g.v("</en/joe_palma>").inc(["</film/performance/actor>"]).count()
        g.close()
        self.assertEqual(res, 7)

        #reload test
        g2 = Graph(graph_name="movies3", cog_path_prefix="/tmp/" + DIR_NAME)
        res2 = g2.v("</en/joe_palma>").inc(["</film/performance/actor>"
                                            ]).count()
        g2.close()
        self.assertEqual(res2, 7, "reload test failed.")