Example #1
0
    def test_import_from_path_loaded_edges_missing_properties_file(self):
        path = create_graph_mock_path()

        # deleted the edges properties file.
        os.remove(
            os.path.join(
                path,
                "edges",
                "knows",
                "0",
                "properties.json"
            )
        )

        graph = PersistentGraph(path)

        marko = graph.get_vertex(0)
        josh = graph.get_vertex(1)
        marko_josh = graph.get_edge(0)

        self.assertEqual(len(graph.edges), 1)
        self.assertEqual(marko_josh.head, marko)
        self.assertEqual(marko_josh.tail, josh)
        self.assertIsInstance(marko_josh, PersistentEdge)
        self.assertEqual(
            marko_josh.path,
            os.path.join(graph.edges_path, "knows", "0"),
        )
        self.assertDictEqual(marko_josh.properties, {})
Example #2
0
    def test_import_from_path_loaded_edges_missing_properties_file(self):
        path = create_graph_mock_path()

        # deleted the edges properties file.
        os.remove(
            os.path.join(
                path,
                "edges",
                "knows",
                "0",
                "properties.json"
            )
        )

        graph = PersistentGraph(path)

        marko = graph.get_vertex(0)
        josh = graph.get_vertex(1)
        marko_josh = graph.get_edge(0)

        self.assertEqual(len(graph.edges), 1)
        self.assertEqual(marko_josh.head, marko)
        self.assertEqual(marko_josh.tail, josh)
        self.assertIsInstance(marko_josh, PersistentEdge)
        self.assertEqual(
            marko_josh.path,
            os.path.join(graph.edges_path, "knows", "0"),
        )
        self.assertDictEqual(marko_josh.properties, {})
Example #3
0
    def test_import_from_path_loaded_edges(self):
        path = create_graph_mock_path()
        graph = PersistentGraph(path)

        self.assertEqual(len(graph.edges), 1)
        marko_josh = graph.get_edge(0)

        self.assertIsInstance(marko_josh, PersistentEdge)

        self.assertEqual(
            marko_josh.path,
            os.path.join(graph.edges_path, "knows", "0"),
        )

        self.assertDictEqual(
            marko_josh.as_dict(),
            {
                "id": 0,
                "label": "knows",
                "metadata": {},
                "head_id": 0,
                "tail_id": 1,
                "properties": {
                    "since": "school",
                },
            }
        )
Example #4
0
    def test_import_from_path_loaded_edges(self):
        path = create_graph_mock_path()
        graph = PersistentGraph(path)

        self.assertEqual(len(graph.edges), 1)
        marko_josh = graph.get_edge(0)

        self.assertIsInstance(marko_josh, PersistentEdge)

        self.assertEqual(
            marko_josh.path,
            os.path.join(graph.edges_path, "knows", "0"),
        )

        self.assertDictEqual(
            marko_josh.as_dict(),
            {
                "id": 0,
                "label": "knows",
                "metadata": {},
                "head_id": 0,
                "tail_id": 1,
                "properties": {
                    "since": "school",
                },
            }
        )