old_contents: import json
  import logging
  from datetime import datetime
  from sst import config
  from testrail_api.testrail import *
  
  logger = logging.getLogger('SST')
  
  client = APIClient('https://dramafever.testrail.net/')
  
  client.user = ''
  client.password = ''
  
  run_results = []
  project_id = 3
  run_id = None
  
  def create_test_run(case_ids):
      time = datetime.now().time().strftime("%I:%M %p")
      try:
          run = client.send_post('add_run/{}'.format(project_id),
              {
                  "name": "Automation Test Run {}".format(time),
                  "include_all": False,
                  "case_ids": case_ids
              }
          )
          return run['id']
      except Exception as e:
          logger.debug("Could not create TestRail test run \n" + str(e))
  
  # add test case results to test run
  def send_results():
      store_json_results(run_results)
      try:
          run = client.send_post('add_results_for_cases/{}'.format(run_id),
      		{ "results": run_results }
          )
      except Exception as e:
          logger.debug("Could not send TestRail results \n" + str(e))
  
  # add individual test case result to test run
  def send_result(case_id, status_id, comment=None):
      result = {
          "status_id": status_id,
          "comment": comment
      }
      store_json_results(result, case_id)
      try:
          run = client.send_post('add_result_for_case/{}/{}'
                                 .format(run_id, case_id), result)
      except Exception as e:
          logger.debug("Could not send TestRail results \n" + str(e))
  
  def store_json_results(result, case_id=''):
      filename = '{}/{}results.json'.format(config.results_directory, case_id)
      with open(filename, 'w') as outfile:
          json.dump(result, outfile)
  
  
  class APITestStatus(object):
  
      PASSED, BLOCKED, RETEST, RETEST, FAILED = range(1, 6)
  
  
  FAILED_TEST_RESULT_STATUS = APITestStatus.FAILED
  
new_contents: import json
  import logging
  from datetime import datetime
  from sst import config
  from testrail_api.testrail import *
  
  logger = logging.getLogger('SST')
  
  class TestRailHelper(object):
  
      def __init__(self, url, user, password, project_id):
          self.client = APIClient(url)
          self.client.user = user
          self.client.password = password
          self.project_id = project_id
          self.run_results = []
          self.run_id = None
  
      def create_test_run(self, case_ids):
          time = datetime.now().time().strftime("%I:%M %p")
          try:
              run = self.client.send_post('add_run/{}'.format(self.project_id),
                    {
                        "name": "Automation Test Run {}".format(time),
                        "include_all": False,
                        "case_ids": case_ids
                    }
              )
              return run['id']
          except Exception as e:
              logger.debug("Could not create TestRail test run \n" + str(e))
  
      # add test case results to test run
      def send_results(self):
          self.store_json_results(self.run_results)
          try:
              run = self.client.send_post('add_results_for_cases/{}'
                        .format(self.run_id),
                        { "results": self.run_results }
              )
          except Exception as e:
              logger.debug("Could not send TestRail results \n" + str(e))
  
      # add individual test case result to test run
      def send_result(self, case_id, status_id, comment=None):
          result = {
              "status_id": status_id,
              "comment": comment
          }
          self.store_json_results(result, case_id)
          try:
              run = self.client.send_post('add_result_for_case/{}/{}'
                                          .format(self.run_id, case_id), result)
          except Exception as e:
              logger.debug("Could not send TestRail results \n" + str(e))
  
      def store_json_results(self, result, case_id=''):
          filename = '{}/{}results.json'.format(config.results_directory, case_id)
          with open(filename, 'w') as outfile:
              json.dump(result, outfile)
  
  
  class APITestStatus(object):
  
      PASSED, BLOCKED, RETEST, RETEST, FAILED = range(1, 6)
  
  
  FAILED_TEST_RESULT_STATUS = APITestStatus.FAILED
  
subject: make the testrail helper a class so we can initialize with the testrail credentials and store the results and run_id as instance variables to more easily access them later