def test_from_prebuilt_unrecognized_name(self):

        root_directory_url = "https://api.github.com/repos/mrucker/coba_prebuilds/contents/"

        def mocked_requests_get(*args, **kwargs):

            if args[0] == root_directory_url:
                return MockResponse(200, b'[{ "name":"test"}]')

            return MockResponse(404, None)

        with unittest.mock.patch.object(requests,
                                        'get',
                                        side_effect=mocked_requests_get):
            with self.assertRaises(CobaException) as e:
                envs = Environments.from_prebuilt("nada")

            self.assertIn('nada', str(e.exception))
            self.assertIn('test', str(e.exception))
    def test_from_prebuilt_recognized_name(self):

        index_url = "https://github.com/mrucker/coba_prebuilds/blob/main/test/index.json?raw=True"
        simulation_url = "https://github.com/mrucker/coba_prebuilds/blob/main/test/test.json?raw=True"

        def mocked_requests_get(*args, **kwargs):

            if args[0] == index_url:
                return MockResponse(
                    200,
                    b'{ "environments": { "SerializedSimulation": "./test.json" } }'
                )

            return MockResponse(None, 404, [])

        with unittest.mock.patch.object(requests,
                                        'get',
                                        side_effect=mocked_requests_get):
            envs = Environments.from_prebuilt("test")

        self.assertEqual(1, len(envs))
        self.assertIsInstance(envs[0], SerializedSimulation)
        self.assertIsInstance(envs[0]._source, UrlSource)
        self.assertEqual(simulation_url, envs[0]._source._url)