def test_hasSetting_When_setting_exists_at_depth_gt_1_Then_returns_true(self): p = Mock() when(p).getUserDataDir().thenReturn('') xml = """ <advancedsettings> <loglevel>0</loglevel> <video> <usetimeseeking>true</usetimeseeking> </video> </advancedsettings> """ s = AdvancedSettings(platform=p, init_with=xml) self.assertTrue(s.hasSetting('video/usetimeseeking')) self.assertFalse(s.hasSetting('video/usetimeseeking/crapola')) self.assertTrue(s.hasSetting('loglevel')) self.assertFalse(s.hasSetting('loglevel/crapola')) self.assertTrue(s.hasSetting('video'))
def test_hasSetting_When_setting_exists_at_depth_eq_1_Then_returns_true( self): p = Mock() when(p).getUserDataDir().thenReturn('') advanced = AdvancedSettings( platform=p, init_with= """<advancedsettings><loglevel>0</loglevel></advancedsettings>""") self.assertTrue(advanced.hasSetting('loglevel'))
def test_hasSetting_When_setting_exists_at_depth_gt_1_Then_returns_true( self): p = Mock() when(p).getUserDataDir().thenReturn('') xml = """ <advancedsettings> <loglevel>0</loglevel> <video> <usetimeseeking>true</usetimeseeking> </video> </advancedsettings> """ s = AdvancedSettings(platform=p, init_with=xml) self.assertTrue(s.hasSetting('video/usetimeseeking')) self.assertFalse(s.hasSetting('video/usetimeseeking/crapola')) self.assertTrue(s.hasSetting('loglevel')) self.assertFalse(s.hasSetting('loglevel/crapola')) self.assertTrue(s.hasSetting('video'))
def test_hasSetting_When_setting_exists_at_depth_eq_1_Then_returns_true(self): p = Mock() when(p).getUserDataDir().thenReturn('') advanced = AdvancedSettings(platform=p, init_with="""<advancedsettings><loglevel>0</loglevel></advancedsettings>""") self.assertTrue(advanced.hasSetting('loglevel'))
def test_hasSetting_When_setting_does_not_exist_Then_returns_false(self): p = Mock() when(p).getUserDataDir().thenReturn('') advanced = AdvancedSettings(platform=p) self.assertFalse(advanced.hasSetting('loglevel'))
def test_constructor_When_seeded_with_xml_as_string(self): p = Mock() when(p).getUserDataDir().thenReturn('') xml = """<advancedsettings><loglevel>0</loglevel></advancedsettings>""" advanced = AdvancedSettings(platform=p, init_with=xml) self.assertTrue(advanced.hasSetting('loglevel'))