def test_corpusDefaultsToInstance(self): args = createSkiaGoldArgs() sgp = skia_gold_properties.SkiaGoldProperties(args) sgsm = skia_gold_session_manager.SkiaGoldSessionManager( self._working_dir, sgp) session = sgsm.GetSkiaGoldSession({}, None, 'instance') self.assertTrue(session._keys_file.startswith(self._working_dir)) self.assertEqual(session._corpus, 'instance') self.assertEqual(session._instance, 'instance')
def test_getDefaultInstance(self, default_instance_mock): default_instance_mock.return_value = 'default' args = createSkiaGoldArgs() sgp = skia_gold_properties.SkiaGoldProperties(args) sgsm = skia_gold_session_manager.SkiaGoldSessionManager( self._working_dir, sgp) session = sgsm.GetSkiaGoldSession({}, None, None) self.assertTrue(session._keys_file.startswith(self._working_dir)) self.assertEqual(session._corpus, 'default') self.assertEqual(session._instance, 'default')
def test_corpusFromJson(self): args = createSkiaGoldArgs() sgp = skia_gold_properties.SkiaGoldProperties(args) sgsm = skia_gold_session_manager.SkiaGoldSessionManager( self._working_dir, sgp) session = sgsm.GetSkiaGoldSession({'source_type': 'foobar'}, None, 'instance') self.assertTrue(session._keys_file.startswith(self._working_dir)) self.assertEqual(session._corpus, 'foobar') self.assertEqual(session._instance, 'instance')
def test_separateSessionsFromCorpus(self, session_mock): session_mock.return_value = None args = createSkiaGoldArgs() sgp = skia_gold_properties.SkiaGoldProperties(args) sgsm = skia_gold_session_manager.SkiaGoldSessionManager( self._working_dir, sgp) session1 = sgsm.GetSkiaGoldSession({}, 'corpus1', 'instance') session2 = sgsm.GetSkiaGoldSession({}, 'corpus2', 'instance') self.assertNotEqual(session1, session2) self.assertEqual(session_mock.call_count, 2)
def test_matchingSessionReused(self, session_mock): session_mock.return_value = None args = createSkiaGoldArgs() sgp = skia_gold_properties.SkiaGoldProperties(args) sgsm = skia_gold_session_manager.SkiaGoldSessionManager( self._working_dir, sgp) session1 = sgsm.GetSkiaGoldSession({}, 'corpus', 'instance') session2 = sgsm.GetSkiaGoldSession({}, 'corpus', 'instance') self.assertEqual(session1, session2) # For some reason, session_mock.assert_called_once() always passes, # so check the call count directly. self.assertEqual(session_mock.call_count, 1)
def test_ArgsForwardedToSession(self): args = createSkiaGoldArgs() sgp = skia_gold_properties.SkiaGoldProperties(args) sgsm = skia_gold_session_manager.SkiaGoldSessionManager( self._working_dir, sgp) session = sgsm.GetSkiaGoldSession({}, 'corpus', 'instance') self.assertTrue(session._keys_file.startswith(self._working_dir)) self.assertEqual(session._corpus, 'corpus') self.assertEqual(session._instance, 'instance') # Make sure the session's working directory is a subdirectory of the # manager's working directory. self.assertEqual(os.path.dirname(session._working_dir), self._working_dir)