Beispiel #1
0
    def test_search_range_neither(self):
        """Test searching a range with only end."""
        query = Dataset()
        query.QueryRetrieveLevel = 'PATIENT'
        query.StudyDate = '-'

        with pytest.raises(ValueError):
            db._search_range(query['StudyDate'], self.session)
Beispiel #2
0
    def test_search_range_end(self):
        """Test searching a range with only end."""
        query = Dataset()
        query.QueryRetrieveLevel = 'PATIENT'
        query.StudyDate = '-20200101'

        q = db._search_range(query['StudyDate'], self.session)
        assert 4 == len(q.all())

        query.StudyDate = '-20150101'
        q = db._search_range(query['StudyDate'], self.session)
        assert 3 == len(q.all())

        query.StudyDate = '-20010101'
        q = db._search_range(query['StudyDate'], self.session)
        assert not q.all()
Beispiel #3
0
    def test_search_range_start(self):
        """Test searching a range with only start."""
        query = Dataset()
        query.QueryRetrieveLevel = "PATIENT"
        query.StudyDate = "20000101-"

        q = db._search_range(query["StudyDate"], self.session)
        assert 4 == len(q.all())

        query.StudyDate = "20150101-"
        q = db._search_range(query["StudyDate"], self.session)
        assert 1 == len(q.all())

        query.StudyDate = "20200101-"
        q = db._search_range(query["StudyDate"], self.session)
        assert not q.all()
Beispiel #4
0
    def test_combine_queries(self):
        """Test combining queries."""
        query = Dataset()
        query.QueryRetrieveLevel = 'PATIENT'
        query.PatientName = 'CompressedSamples*'
        query.StudyDate = '20000101-20040119'

        q1 = db._search_wildcard(query['PatientName'], self.session)
        q2 = db._search_range(query['StudyDate'], self.session)
        q = q1.intersect(q2)
        assert 1 == len(q.all())