Exemplo n.º 1
0
    def test_generate_copy_tasks_for_fonts(self):
        """Test _generate_copy_tasks_for_fonts ensures that the number of copy
        tasks matches the number of font files.
        """
        copy_tasks = collections.deque()
        # Get all filepaths from manifest.json.
        dependency_filepaths = build.get_dependencies_filepaths()
        # Setup a sandbox folder for copying fonts.
        test_target = os.path.join('target', 'fonts', '')

        self.assertEqual(len(copy_tasks), 0)
        copy_tasks += build._generate_copy_tasks_for_fonts(
            dependency_filepaths['fonts'], test_target)
        # Asserting the same number of copy tasks and number of font files.
        self.assertEqual(len(copy_tasks), len(dependency_filepaths['fonts']))
Exemplo n.º 2
0
 def test_join_files(self):
     """Determine third_party.js contains the content of the first 10 JS
     files in /third_party/static.
     """
     # Prepare a file_stream object from StringIO.
     third_party_js_stream = StringIO.StringIO()
     # Get all filepaths from manifest.json.
     dependency_filepaths = build.get_dependencies_filepaths()
     # Join and write all JS files in /third_party/static to file_stream.
     build._join_files(dependency_filepaths['js'], third_party_js_stream)
     counter = 0
     # Only checking first 10 files.
     JS_FILE_COUNT = 10
     for js_filepath in dependency_filepaths['js']:
         if counter == JS_FILE_COUNT:
             break
         with open(js_filepath, 'r') as js_file:
             # Assert that each line is copied over to file_stream object.
             for line in js_file:
                 self.assertIn(line, third_party_js_stream.getvalue())
         counter += 1