Example #1
0
    def test_correct_values(self):
        """Tests that the parameters in the written TO file are as expected
        """
        # Create a test config file containing the test database
        parameters = utilities.read_TO_file(adripy.get_full_path(os.path.join(f'<{TEST_DATABASE_NAME}>', 'drill_strings.tbl', TEST_EXISTING_STRING_NAME + '.str')))

        self.assertDictEqual(parameters, EXPECTED_STRING_TO_PARAMETERS)    
    def test_publish_string_with_duplicate_tools_to_new_database_1(self):
        """Test the `DrillString.write_to_file()` method with publish=True when the string contains two of the same stabilizer.  The criteria for this test is that only a single tool file is published to the database even though the tool is used twice.

        Notes
        -----
            This test intentionally uses a string that uses the same tool twice.            
        """
        # Create a DrillString object
        drill_string = adripy.DrillString(TEST_STRING_NAME, TEST_EXISTING_HOLE_FILE, TEST_EVENT_FILE)

        # Add the DrillTool objects to the DrillString object
        drill_string.add_tool(self.pdc_bit, measure='yes')
        drill_string.add_tool(self.stabilizer, measure='yes')
        drill_string.add_tool(self.mwd, measure='yes')
        drill_string.add_tool(self.upper_stabilizer, measure='yes')
        drill_string.add_tool(self.drill_pipe, joints=20, group_name='Upper_DP_Group')
        drill_string.add_tool(self.eus, joints=20, group_name='equivalent_pipe', equivalent=True)
        drill_string.add_tool(self.top_drive)

        # Publish drill string to new database
        drill_string.write_to_file(cdb=TEST_NEW_DATABASE_NAME, publish=True, publish_event=True)

        expected_files = [adripy.get_full_path(drill_string.tools[1]['Property_File'])]
        actual_files = glob.glob(os.path.join(TEST_NEW_DATABASE_PATH, 'stabilizers.tbl', '*'))

        self.assertListEqual(actual_files, expected_files)    
Example #3
0
 def test_full_path_works(self):
     """Tests if :meth:`read_TO_file` works with a full path is passed.
     """
     try:
         _parameters = utilities.read_TO_file(adripy.get_full_path(os.path.join(f'<{TEST_DATABASE_NAME}>', 'drill_strings.tbl', TEST_EXISTING_STRING_NAME + '.str')))
     except FileNotFoundError:
         self.fail('File not found when full path used')
    def test_get_full_path(self):
        """Test that adripy.get_full_path returns the correct path.
        """
        expected_full_path = os.path.join(EXISTING_CDB_PATH, 'stabilizers.tbl', EXAMPLE_STABILIZER_NAME + '.sta')
        example_cdb_path = os.path.join(f'<{EXISTING_CDB_NAME}>', 'stabilizers.tbl', EXAMPLE_STABILIZER_NAME + '.sta')
        full_path = adripy.get_full_path(example_cdb_path)

        self.assertEqual(full_path, expected_full_path)
    def test_get_full_path_is_case_insensitive(self):
        """Test that adripy.get_full_path returns the correct path when the input path has the wrong case.
        """
        cdb_name_wrong_case = EXISTING_CDB_NAME.lower() if not EXISTING_CDB_NAME.islower() else EXISTING_CDB_NAME.upper()
        expected_full_path = os.path.join(EXISTING_CDB_PATH, 'stabilizers.tbl', EXAMPLE_STABILIZER_NAME + '.sta')
        example_cdb_path = os.path.join(f'<{cdb_name_wrong_case}>', 'stabilizers.tbl', EXAMPLE_STABILIZER_NAME + '.sta')
        full_path = adripy.get_full_path(example_cdb_path)

        self.assertEqual(full_path, expected_full_path)
    def test_replace_tool_new_tool_uses_cdb_path(self):
        """Tests that adripy.utilities.replace_tool() works as expected

        """
        # Copy string
        temp_string_file = os.path.join(TEST_DATABASE_PATH, 'drill_strings.tbl', 'temp.str')        
        shutil.copyfile(adripy.get_full_path(TEST_EXISTING_STRING_FILE), temp_string_file)
        
        # Replace stabilizer in string
        fake_stabilizer_file = os.path.join(f'<{TEST_DATABASE_NAME}>', 'stabilizers.tbl', 'fake_stabilizer.sta')
        adripy.replace_tool(adripy.get_cdb_path(temp_string_file), TEST_STABILIZER_FILE, fake_stabilizer_file)
        
        # Check new string file contents
        failures = check_file_contents(temp_string_file, TEST_EXPECTED_STRING_CONTENTS_AFTER_REPLACE)

        # Delete new string
        os.remove(temp_string_file)

        # Assert correct string file contents
        self.assertListEqual(failures, [])
 def test_get_full_path_abs_path(self):
     dummy_file = os.path.join(os.getcwd(), 'non_existent_file.txt')
     full_filepath = adripy.get_full_path(dummy_file)
     self.assertEqual(full_filepath, os.path.join(dummy_file))