Пример #1
0
    def test_get_versions_dict(self):
        with self.subTest('test_empty.yml'):
            result = CheckNewVersion.get_versions_dict(utils.full_path_from_relative_path('data/test_empty.yml'))
            self.assertEqual(result, {})

        with self.subTest('test_unitysetup_2019.yml'):
            result = CheckNewVersion.get_versions_dict(
                utils.full_path_from_relative_path('data/test_unitysetup_2019.yml')
            )
            self.assertEqual(list(result.keys()), ['2019.1.3f1'])
Пример #2
0
    def do_test_snapshot(self, ci_generator, version_input, version_output):
        version_input_full_path = full_path_from_relative_path(version_input)
        version_output_full_path = full_path_from_relative_path(version_output)
        with captured_output() as (out, err):
            with mock.patch(f'{self.class_path}.get_unity_versions_path'
                            ) as mocked_get_unity_versions_path:
                mocked_get_unity_versions_path.return_value = version_input_full_path
                ci_generator.output()
        output = out.getvalue().strip()

        if os.environ.get('UPDATE_SNAPSHOTS'):  # no cover
            with open(version_output_full_path, 'w') as f:  # no cover
                f.write(output)  # no cover

        with open(version_output_full_path) as f:
            self.maxDiff = None
            self.assertEqual(output, f.read())
Пример #3
0
 def test_generate_unity_version_block(self):
     check_new_version = CheckNewVersion()
     with open(utils.full_path_from_relative_path('data/releases-linux.json')) as f:
         json_text = f.read()
     official_release = json.loads(json_text)['official'][0]
     version_block = check_new_version.generate_unity_version_block(official_release)
     self.assertEqual(version_block, {
         '2017.4.27f1': {
             'build': 'f1',
             'dockerfile_name': 'unitysetup',
             'download_url': 'https://beta.unity3d.com/download/0c4b856e4c6e/UnitySetup-2017.4.27f1',
             'release_notes': 'https://unity3d.com/unity/whats-new/2017.4.27f1',
             'release_url': 'https://beta.unity3d.com/download/0c4b856e4c6e/public_download.html',
             'sha1': '8dae4dd18df383a598830c6e2489cdecdcb19273',
             'underscore': '2017_4_27f1',
             'version': '2017.4.27'
         }
     })
Пример #4
0
 def test_sha1(self):
     file_name = utils.full_path_from_relative_path('data/releases-linux.json')
     result = CheckNewVersion.sha1(file_name)
     self.assertEqual(result, 'b0d8c80edcc0e501b4fbf7c2d09e6205e7d77ec8')
Пример #5
0
 def mock_releases_json_get(mocked_request):
     with open(utils.full_path_from_relative_path('data/releases-linux.json'), 'r') as f:
         json_text = f.read()
     mocked_request.get('https://public-cdn.cloud.unity3d.com/hub/prod/releases-linux.json', text=json_text)
     return json_text
Пример #6
0
 def test_render_template(self):
     template = full_path_from_relative_path('data/test.jinja2')
     rendered_template = GitlabCiGenerator.render_template(
         template, {'context_data': 'test'})
     self.assertEqual(rendered_template, 'example with test')