コード例 #1
0
    def test_repr(self):
        relation = Relation(id=1, resolwe=MagicMock())
        relation.type = 'compare'
        relation.unit = 'min'
        relation.category = 'background'

        # `name` cannot be mocked in another way
        sample_1 = MagicMock()
        sample_1.configure_mock(name='sample_1')
        sample_2 = MagicMock()
        sample_2.configure_mock(name='sample_2')
        relation._samples = [sample_1, sample_2]

        # Positions and labels are given
        relation.partitions = [
            {'id': 3, 'entity': 1, 'position': 10, 'label': 'first'},
            {'id': 4, 'entity': 2, 'position': 20, 'label': 'second'},
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {first (10 min): sample_1, second (20 min): sample_2}"
        )

        # Only labels are given
        relation.partitions = [
            {'id': 3, 'entity': 1, 'position': None, 'label': 'first'},
            {'id': 4, 'entity': 2, 'position': None, 'label': 'second'},
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {first: sample_1, second: sample_2}"
        )

        # Only positions are given
        relation.partitions = [
            {'id': 3, 'entity': 1, 'position': 10, 'label': None},
            {'id': 4, 'entity': 2, 'position': 20, 'label': None},
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {10 min: sample_1, 20 min: sample_2}"
        )

        # Only sample names are given
        relation.partitions = [
            {'id': 3, 'entity': 1, 'position': None, 'label': None},
            {'id': 4, 'entity': 2, 'position': None, 'label': None},
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {sample_1, sample_2}"
        )
コード例 #2
0
    def test_repr(self):
        relation = Relation(id=1, resolwe=MagicMock())
        relation.type = 'compare'
        relation.unit = 'min'
        relation.category = 'background'

        # `name` cannot be mocked in another way
        sample_1 = MagicMock()
        sample_1.configure_mock(name='sample_1')
        sample_2 = MagicMock()
        sample_2.configure_mock(name='sample_2')
        relation._samples = [sample_1, sample_2]

        # Positions and labels are given
        relation.partitions = [
            {'id': 3, 'entity': 1, 'position': 10, 'label': 'first'},
            {'id': 4, 'entity': 2, 'position': 20, 'label': 'second'},
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {first (10 min): sample_1, second (20 min): sample_2}"
        )

        # Only labels are given
        relation.partitions = [
            {'id': 3, 'entity': 1, 'position': None, 'label': 'first'},
            {'id': 4, 'entity': 2, 'position': None, 'label': 'second'},
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {first: sample_1, second: sample_2}"
        )

        # Only positions are given
        relation.partitions = [
            {'id': 3, 'entity': 1, 'position': 10, 'label': None},
            {'id': 4, 'entity': 2, 'position': 20, 'label': None},
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {10 min: sample_1, 20 min: sample_2}"
        )

        # Only sample names are given
        relation.partitions = [
            {'id': 3, 'entity': 1, 'position': None, 'label': None},
            {'id': 4, 'entity': 2, 'position': None, 'label': None},
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {sample_1, sample_2}"
        )
コード例 #3
0
    def test_repr(self):
        relation = Relation(id=1, resolwe=MagicMock())
        relation.type = "compare"
        relation.unit = "min"
        relation.category = "background"

        # `name` cannot be mocked in another way
        sample_1 = MagicMock()
        sample_1.configure_mock(name="sample_1")
        sample_2 = MagicMock()
        sample_2.configure_mock(name="sample_2")
        relation._samples = [sample_1, sample_2]

        # Positions and labels are given
        relation.partitions = [
            {
                "id": 3,
                "entity": 1,
                "position": 10,
                "label": "first"
            },
            {
                "id": 4,
                "entity": 2,
                "position": 20,
                "label": "second"
            },
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {first (10 min): sample_1, second (20 min): sample_2}",
        )

        # Only labels are given
        relation.partitions = [
            {
                "id": 3,
                "entity": 1,
                "position": None,
                "label": "first"
            },
            {
                "id": 4,
                "entity": 2,
                "position": None,
                "label": "second"
            },
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {first: sample_1, second: sample_2}",
        )

        # Only positions are given
        relation.partitions = [
            {
                "id": 3,
                "entity": 1,
                "position": 10,
                "label": None
            },
            {
                "id": 4,
                "entity": 2,
                "position": 20,
                "label": None
            },
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {10 min: sample_1, 20 min: sample_2}",
        )

        # Only sample names are given
        relation.partitions = [
            {
                "id": 3,
                "entity": 1,
                "position": None,
                "label": None
            },
            {
                "id": 4,
                "entity": 2,
                "position": None,
                "label": None
            },
        ]
        self.assertEqual(
            str(relation),
            "Relation id: 1, type: 'compare', category: 'background', "
            "samples: {sample_1, sample_2}",
        )