# Path: q2_types/distance_matrix/_format.py
# class LSMatFormat(model.TextFileFormat):
#     def sniff(self):


import os.path
import shutil
import unittest
from q2_types.distance_matrix import LSMatFormat, DistanceMatrixDirectoryFormat
from qiime2.plugin.testing import TestPluginBase
from qiime2.plugin import ValidationError
    def test_lsmat_format_validate_positive(self):
        filenames = ('distance-matrix-1x1.tsv', 'distance-matrix-2x2.tsv',
                     'distance-matrix-NxN.tsv')
        for filename in filenames:
            filepath = self.get_data_path(filename)
            format = LSMatFormat(filepath, mode='r')

            # Should not error.
            format.validate()

    def test_lsmat_format_validate_negative(self):
        filepath = self.get_data_path('not-lsmat')
        format = LSMatFormat(filepath, mode='r')

        with self.assertRaisesRegex(ValidationError, 'LSMat'):
            format.validate()

    def test_distance_matrix_directory_format(self):
        # This test exists mainly to assert that the single-file directory
        # format is defined and functional. More extensive testing is performed
        # on its underlying format (LSMatFormat).
        filepath = self.get_data_path('distance-matrix-NxN.tsv')
        shutil.copy(filepath,
                    os.path.join(self.temp_dir.name, 'distance-matrix.tsv'))
        format = DistanceMatrixDirectoryFormat(self.temp_dir.name, mode='r')

        # Should not error.
        format.validate()



# Path: q2_types/distance_matrix/_format.py
# class LSMatFormat(model.TextFileFormat):
#     def sniff(self):


# Path: q2_types/distance_matrix/tests/test_format.py
import os.path
import shutil
import unittest
from q2_types.distance_matrix import LSMatFormat, DistanceMatrixDirectoryFormat
from qiime2.plugin.testing import TestPluginBase
from qiime2.plugin import ValidationError

    def test_lsmat_format_validate_positive(self):
        filenames = ('distance-matrix-1x1.tsv', 'distance-matrix-2x2.tsv',
                     'distance-matrix-NxN.tsv')
        for filename in filenames:
            filepath = self.get_data_path(filename)
            format = LSMatFormat(filepath, mode='r')

            # Should not error.
            format.validate()

    def test_lsmat_format_validate_negative(self):
        filepath = self.get_data_path('not-lsmat')
        format = LSMatFormat(filepath, mode='r')

        with self.assertRaisesRegex(ValidationError, 'LSMat'):
            format.validate()

    def test_distance_matrix_directory_format(self):
        # This test exists mainly to assert that the single-file directory
        # format is defined and functional. More extensive testing is performed
        # on its underlying format (LSMatFormat).
        filepath = self.get_data_path('distance-matrix-NxN.tsv')
        shutil.copy(filepath,
                    os.path.join(self.temp_dir.name, 'distance-matrix.tsv'))
        format = DistanceMatrixDirectoryFormat(self.temp_dir.name, mode='r')

        # Should not error.
        format.validate()



if __name__ == "__main__":