コード例 #1
0
ファイル: utils_test.py プロジェクト: jameesjohn/oppia
 def test_get_exploration_components_from_dir_with_no_yaml_file(
         self) -> None:
     with self.assertRaisesRegexp(  # type: ignore[no-untyped-call]
             Exception,
             'No yaml file specifed for core/tests/data/dummy_assets'):
         utils.get_exploration_components_from_dir(
             'core/tests/data/dummy_assets/')
コード例 #2
0
ファイル: utils_test.py プロジェクト: jameesjohn/oppia
 def test_get_exploration_components_from_dir_with_multiple_yaml_files(
         self) -> None:
     with self.assertRaisesRegexp(  # type: ignore[no-untyped-call]
             Exception, 'More than one non-asset file specified for '
             'core/tests/data/dummy_assets/assets'):
         utils.get_exploration_components_from_dir(
             'core/tests/data/dummy_assets/assets/')
コード例 #3
0
ファイル: utils_test.py プロジェクト: jameesjohn/oppia
    def test_get_exploration_components_from_dir_with_invalid_path_raises_error(
            self) -> None:
        with self.assertRaisesRegexp(  # type: ignore[no-untyped-call]
                Exception, 'Found invalid non-asset file .+'
                'There should only be a single non-asset file, and it should have '
                'a .yaml suffix.'):
            utils.get_exploration_components_from_dir('core/tests/load_tests')

        with self.assertRaisesRegexp(  # type: ignore[no-untyped-call]
                Exception, 'The only directory in . should be assets/'):
            utils.get_exploration_components_from_dir('.')
コード例 #4
0
 def test_get_exploration_components_from_dir_with_yaml_content(self) -> None:  # pylint: disable=line-too-long
     img1_path = 'images/sample_Img.svg'
     img2_path = 'images/sample_Img2.svg'
     img1_file_content = b'<svg width="100" height="100"><circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" /></svg>\n'  # pylint: disable=line-too-long
     img2_file_content = b'<svg width="400" height="110"><rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" /></svg>\n'  # pylint: disable=line-too-long
     yaml_content = 'name: John Smith\ncontact:\n    home:   1012355532\n    office:  5002586256\naddress:\n  street: |\n            123 Tornado Alley\n            Suite 16            \n    city:   East Centerville\n    state:  KS'  # pylint: disable=line-too-long
     result = utils.get_exploration_components_from_dir(
         'core/tests/data/dummy_assets_yaml')
     final_result = (result[0], set(result[1]))
     self.assertEqual(final_result, (yaml_content,
                                     set([(img2_path, img2_file_content),
                                          (img1_path, img1_file_content)])))