Beispiel #1
0
    def test_scopeString(self):
        # this is an usual scope with facility, poc and bed
        expectedScopeStringWpf = self.scope_prefix + '/HOSP1%2FCU1%2FBedA500?fac=HOSP1&poc=CU1&bed=BedA500'
        loc = SdcLocation(fac='HOSP1', poc='CU1', bed='BedA500')
        self.assertEqual(loc.root, self.default_root)
        self.assertEqual(loc.fac, 'HOSP1')
        self.assertEqual(loc.poc, 'CU1')
        self.assertEqual(loc.bed, 'BedA500')
        self.assertEqual(loc.rm, None)
        self.assertEqual(loc.bld, None)
        self.assertEqual(loc.flr, None)
        scopeString = loc.scopeStringWpf
        self.assertEqual(loc.scopeStringWpf, expectedScopeStringWpf)

        expectedScopeStringSdc = self.scope_prefix + '/HOSP1%2F%2F%2FCU1%2F%2FBedA500?fac=HOSP1&poc=CU1&bed=BedA500'
        loc = SdcLocation(fac='HOSP1', poc='CU1', bed='BedA500')
        self.assertEqual(loc.root, self.default_root)
        self.assertEqual(loc.fac, 'HOSP1')
        self.assertEqual(loc.poc, 'CU1')
        self.assertEqual(loc.bed, 'BedA500')
        self.assertEqual(loc.rm, None)
        self.assertEqual(loc.bld, None)
        self.assertEqual(loc.flr, None)
        scopeString = loc.scopeStringWpf
        self.assertEqual(loc.scopeStringSdc, expectedScopeStringSdc)

        # this is an unusual scope with bed only plus root
        expectedScopeString = self.scheme + ':/myroot/BedA500?bed=BedA500'
        loc = SdcLocation(bed='BedA500', root='myroot')
        self.assertEqual(loc.root, 'myroot')
        self.assertEqual(loc.fac, None)
        self.assertEqual(loc.poc, None)
        self.assertEqual(loc.bed, 'BedA500')
        self.assertEqual(loc.rm, None)
        self.assertEqual(loc.bld, None)
        self.assertEqual(loc.flr, None)
        scopeString = loc.scopeStringWpf
        self.assertEqual(scopeString, expectedScopeString)

        # this is an unusual scope with all parameters and spaces in them
        expectedScopeString = self.scheme + ':/some%20where/HOSP%201%2Fabc%201%2FCU%201%2Fflr%201%2FrM%201%2FBed%20A500?room=rM+1&flr=flr+1&bed=Bed+A500&bld=abc+1&fac=HOSP+1&poc=CU+1'
        loc = SdcLocation(fac='HOSP 1', poc='CU 1', bed='Bed A500', flr='flr 1', rm='rM 1', bld='abc 1', root='some where')
        self.assertEqual(loc.root, 'some where')
        self.assertEqual(loc.fac, 'HOSP 1')
        self.assertEqual(loc.poc, 'CU 1')
        self.assertEqual(loc.bed, 'Bed A500')
        self.assertEqual(loc.rm, 'rM 1')
        self.assertEqual(loc.bld, 'abc 1')
        self.assertEqual(loc.flr, 'flr 1')

        self.assertEqual(loc, SdcLocation.fromScopeString(loc.scopeStringWpf))
        self.assertEqual(loc, SdcLocation.fromScopeString(loc.scopeStringSdc))
Beispiel #2
0
    def test_fromScopeString(self):
        scopeStringSdc = self.scope_prefix + '/HOSP1%2F%2F%2FCU1%2F%2FBedA500?fac=HOSP1&poc=CU1&bed=BedA500'
        loc = SdcLocation.fromScopeString(scopeStringSdc)
        self.assertEqual(loc.root, self.default_root)
        self.assertEqual(loc.fac, 'HOSP1')
        self.assertEqual(loc.poc, 'CU1')
        self.assertEqual(loc.bed, 'BedA500')
        self.assertEqual(loc.rm, None)
        self.assertEqual(loc.bld, None)
        self.assertEqual(loc.flr, None)
        self.assertEqual(loc.scopeStringSdc, scopeStringSdc)

        # correct handling of scope with %20 spaces and + char in query
        scopeString = self.scheme + ':/some%20where/HOSP%201%2Fabc%201%2FCU%201%2Fflr%201%2FrM%201%2FBed%20A500?rm=rM+1&flr=flr+1&bed=Bed+A500&bldng=abc+1&fac=HOSP+1&poc=CU+1'
        loc = SdcLocation.fromScopeString(scopeString)
        self.assertEqual(loc.root, 'some where')
        self.assertEqual(loc.fac, 'HOSP 1')
        self.assertEqual(loc.poc, 'CU 1')
        self.assertEqual(loc.bed, 'Bed A500')
        self.assertEqual(loc.rm, 'rM 1')
        self.assertEqual(loc.bld, 'abc 1')
        self.assertEqual(loc.flr, 'flr 1')

        #if we can create another identical  DraegerLocation from loc, then scopeString also seems okay.
        self.assertEqual(loc, SdcLocation.fromScopeString(loc.scopeStringSdc))

        # correct handling of scope with %20 spaces also in query
        for scopeString in (
                self.scheme +
                ':/some%20where/HOSP%201%2Fabc%201%2FCU%201%2Fflr%201%2FrM%201%2FBed%20A500?rm=rM%201&flr=flr%201&bed=Bed+A500&bldng=abc+1&fac=HOSP+1&poc=CU+1',
                self.scheme +
                ':/some%20where/this_part_of string_does_not_matter?rm=rM%201&flr=flr%201&bed=Bed+A500&bldng=abc+1&fac=HOSP+1&poc=CU+1'
        ):
            loc = SdcLocation.fromScopeString(scopeString)
            self.assertEqual(loc.root, 'some where')
            self.assertEqual(loc.fac, 'HOSP 1')
            self.assertEqual(loc.poc, 'CU 1')
            self.assertEqual(loc.bed, 'Bed A500')
            self.assertEqual(loc.rm, 'rM 1')
            self.assertEqual(loc.bld, 'abc 1')
            self.assertEqual(loc.flr, 'flr 1')