def test_query_facility_id(self):
     test_query = '''query{
     metadata {
         facilities(referenceId:"18116481"){
             name
             id
             created
             createdBy
             referenceId
             code
             type
             aliases {
                 name
                 code
                 description
             }
         }
     
     }
 }'''
     authInfo = auth.AuthInfo()
     try:
         authInfo.init_from_env_vars()
         authObj = auth.Authenticate(authInfo)
         token = authObj.authenticate()
         query_obj = graph.Graph(token)
         result = query_obj.query(test_query)
     except Exception as err:
         self.fail("Query failed with error:" + str(err))
예제 #2
0
 def test_lithology(self):
     entity="2/4-X-4 A"
     query=queries.get_drilling_lithology_description(entity)
     try:
         query_obj=graph.Graph(self.token)
         result=query_obj.query(query)
         #have the dict send it to a panda frame creation
         drilling_frames.lithology_info_to_frame(result)
     except Exception as err:
         self.fail("Query drilling lithology failed with error:"+str(err)) 
예제 #3
0
 def test_status_info(self):
     start="2020-01-21T23:00:00.000Z"
     end="2020-03-26T12:00:00.000Z"
     entity="34/4-M-4 H"
     query=queries.get_drilling_status_info_query(start,end,entity)
     try:
         query_obj=graph.Graph(self.token)
         result=query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame=drilling_frames.status_info_to_frame(result)
     except Exception as err:
         self.fail("Query drilling status info failed with error:"+str(err)) 
 def test_production_volumes(self):
     start = "2017-10-31T23:00:00.000Z"
     end = "2017-11-20T12:00:00.000Z"
     entity = "34/10-A-23"
     volume_type = '"Production"'
     query = queries.get_production_volumes(start, end, entity, volume_type)
     try:
         query_obj = graph.Graph(self.token)
         result = query_obj.query(query)
         #have the dict send it to a panda frame creation
         production_frames.production_volumes_to_frame(result)
     except Exception as err:
         self.fail("Query production volumes failed with error:" + str(err))
    def test_query_field_name_to_file(self):
        test_query = '''query{
                metadata {
                    fields(name:"OSEBERG"){
                        name
                        id
                        status
                        created
                        createdBy
                        validFrom
                        validTo
                        description
                        code 
                        country
                        referenceId
                        license {
                            name

                        }
                        wells{
                            name
                            referenceId
                        
                            
                        }
                        platforms {
                            name
                            referenceId
                        }
                    
                        wellbores{
                            name
                            referenceId
                        }
                    
                    }
                    
                }
                
            }'''
        authInfo = auth.AuthInfo()
        result_file = os.path.join(
            os.path.dirname(__file__) + "/data/", 'field_result.json')
        try:
            authInfo.init_from_env_vars()
            authObj = auth.Authenticate(authInfo)
            token = authObj.authenticate()
            query_obj = graph.Graph(token)
            query_obj.query_to_file(test_query, result_file)
        except Exception as err:
            self.fail("Query failed with error:" + str(err))
예제 #6
0
 def test_lithology_to_excel(self):
     entity="2/4-X-4 A"
     query=queries.get_drilling_lithology_description(entity)
     result_file = os.path.join(os.path.dirname(__file__)+"/data/", 'drilling_lithology_result.csv')
     try:
         query_obj=graph.Graph(self.token)
         result=query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame=drilling_frames.lithology_info_to_frame(result)
         #write the data to a csv file
         frame_utils.frame_to_csv(normalized_frame,result_file)
         print ("CSV result written to:"+result_file)
     except Exception as err:
         self.fail("Query drilling lithology failed with error:"+str(err)) 
예제 #7
0
 def test_status_info_to_excel(self):
     result_file = os.path.join(os.path.dirname(__file__)+"/data/", 'drilling_status_info_result.xlsx')
     start="2020-01-21T23:00:00.000Z"
     end="2020-03-26T12:00:00.000Z"
     entity="34/4-M-4 H"
     query=queries.get_drilling_status_info_query(start,end,entity)
     try:
         query_obj=graph.Graph(self.token)
         result=query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame=drilling_frames.status_info_to_frame(result)
         #write the data to a csv file
         frame_utils.frame_to_excel(normalized_frame,result_file)
         print ("Excel result written to:"+result_file)
     except Exception as err:
         self.fail("Query drilling status info failed with error:"+str(err))
예제 #8
0
 def test_production_volumes_to_excel(self):
     result_file = os.path.join(os.path.dirname(__file__)+"/data/", 'production_volumes_result_from_config.xlsx')
     start="2021-03-18"
     end="2021-03-20"
     entity="ALVE"
     volume_type='"Production","Injection","Consumption","Comments"'
     query=queries.get_production_volumes(start,end,entity,volume_type)
     
     try: 
         query_obj=graph.Graph(self.token,self.subscriptionKey,self.graphUrl)
         result=query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame=production_frames.production_volumes_to_frame(result)
         #write the data to a csv file
         frame_utils.frame_to_excel(normalized_frame,result_file)
         print ("Excel result written to:"+result_file)
     except Exception as err:
         self.fail("Query production volumes failed with error:"+str(err))       
    def test_query_drilling_activities(self):
        query = '''
        query {
  drilling {
    drillingActivity(
      limit: 1000
      period_after: "2020-03-21T23:00:00.000Z"
      period_before: "2020-03-26T12:00:00.000Z"
    ) {
      created
      modified
      endTime
      startTime
      dataStartTime
      dataEndTime
      dataEntity {
        name
        type
      }
     conveyance
     state
     stateDetailActivity
     phase
     proprietaryCode
     comment
    
     
   
  }
  }
}
        '''
        authInfo = auth.AuthInfo()
        result_file = os.path.join(
            os.path.dirname(__file__) + "/data/",
            'drilling_activities_result.json')
        try:
            authInfo.init_from_env_vars()
            authObj = auth.Authenticate(authInfo)
            token = authObj.authenticate()
            query_obj = graph.Graph(token)
            query_obj.query_to_file(query, result_file)
        except Exception as err:
            self.fail("Query failed with error:" + str(err))
 def test_production_volumes_to_excel(self):
     result_file = os.path.join(
         os.path.dirname(__file__) + "/data/",
         'production_volumes_result.xlsx')
     start = "2008-01-01"
     end = "2009-12-31"
     entity = "VOLVE"
     volume_type = '"Production"'
     query = queries.get_production_volumes(start, end, entity, volume_type)
     try:
         query_obj = graph.Graph(self.token)
         result = query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame = production_frames.production_volumes_to_frame(
             result)
         #write the data to a csv file
         frame_utils.frame_to_excel(normalized_frame, result_file)
         print("Excel result written to:" + result_file)
     except Exception as err:
         self.fail("Query production volumes failed with error:" + str(err))
 def test_production_volumes_to_csv(self):
     result_file = os.path.join(
         os.path.dirname(__file__) + "/data/",
         'production_volumes_result.csv')
     start = "2017-10-31T23:00:00.000Z"
     end = "2017-11-20T12:00:00.000Z"
     entity = "34/10-A-23"
     volume_type = '"Production"'
     query = queries.get_production_volumes(start, end, entity, volume_type)
     try:
         query_obj = graph.Graph(self.token)
         result = query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame = production_frames.production_volumes_to_frame(
             result)
         #write the data to a csv file
         frame_utils.frame_to_csv(normalized_frame, result_file)
         print("CSV result written to:" + result_file)
     except Exception as err:
         self.fail("Query production volumes failed with error:" + str(err))
 def __run_query(self, query):
     graph_obj = graph.Graph(self.__token)
     return graph_obj.query(query)