Exemple #1
0
    def test_run_multiple_batch(self):
        statements = [neo4j.Statement(self.cypher1), neo4j.Statement(self.cypher2)]
        response = self.connector.run_multiple(statements, batch_size=1)

        statement_1_first_row = response[0][0]
        assert "a" in statement_1_first_row.keys()

        statement_2_first_row = response[1][0]
        assert "b" in statement_2_first_row.keys()
Exemple #2
0
    def test_run_multiple_batch(self, mock_get):
        statements = [neo4j.Statement(self.cypher1), neo4j.Statement(self.cypher2)]
        response = self.connector.run_multiple(statements, batch_size=1)

        statement_1_first_row = response[0][0]
        self.assertEqual(statement_1_first_row['key-cypher-1'], 'value-cypher-1')

        statement_2_first_row = response[1][0]
        self.assertEqual(statement_2_first_row['key-cypher-2'], 'value-cypher-2')

        # check that post has been called 2 times (i.e. 2 batches of a single statement per post request)
        self.assertEqual(mock_get.call_count, 2)
Exemple #3
0
    def test_post(self, mock_get):
        hostname = 'hostname'
        credentials = ('username', 'password')

        connector = neo4j.Connector(hostname, credentials)
        connector.post([neo4j.Statement(self.cypher1)])

        expected_endpoint = hostname + connector.default_path

        mock_get.assert_called_once_with(expected_endpoint, auth=credentials,
                                         json={'statements': [{'statement': self.cypher1}]})