<commit_before>from nextcloudappstore.core.tests.e2e import NEWS_ARCHIVE_URL, \
    NEWS_ARCHIVE_SIGNATURE, \
    NEWS_CERT
from nextcloudappstore.core.tests.e2e.base import BaseStoreTest


class UploadAppReleaseTest(BaseStoreTest):
    fixtures = [
        'categories.json',
        'databases.json',
        'licenses.json',
        'nextcloudreleases.json',
    ]

    def test_upload(self):
        self.login()

        def check_app_version_page(el):
            self.go_to_app('news')
            a = self.by_css(
                '#downloads + table tr:first-child td:nth-child(2) a')

            self.assertEqual('11.0.5', a.text)
            self.assertEqual(NEWS_ARCHIVE_URL, a.get_attribute('href'))

        def upload_app(el):
            self._upload_app(NEWS_ARCHIVE_URL, NEWS_ARCHIVE_SIGNATURE)
            self.wait_for('.global-success-msg', check_app_version_page)

        # this signature is secret so ignore cert checks here
        with self.settings(VALIDATE_CERTIFICATES=False):
            self._register_app(NEWS_CERT, 'test')

        # and run them for uploading the app archive
        with self.settings(VALIDATE_CERTIFICATES=True):
            self.wait_for('.global-success-msg', upload_app)

    def _upload_app(self, url, sig):
        self.go_to_app_upload()
        self.by_id('id_download').send_keys(url)
        self.by_id('id_signature').send_keys(sig)
        self.by_id('submit').click()

    def _register_app(self, cert, sig):
        self.go_to_app_register()<commit_msg>add additional test for releases page<commit_after>from nextcloudappstore.core.tests.e2e import NEWS_ARCHIVE_URL, \
    NEWS_ARCHIVE_SIGNATURE, \
    NEWS_CERT
from nextcloudappstore.core.tests.e2e.base import BaseStoreTest


class UploadAppReleaseTest(BaseStoreTest):
    fixtures = [
        'categories.json',
        'databases.json',
        'licenses.json',
        'nextcloudreleases.json',
    ]

    def test_upload(self):
        self.login()

        def check_app_version_page(el):
            self.go_to_app('news')
            a = self.by_css(
                '#downloads + table tr:first-child td:nth-child(2) a')

            self.assertEqual('11.0.5', a.text)
            self.assertEqual(NEWS_ARCHIVE_URL, a.get_attribute('href'))

            self.by_css(
                '#downloads + table tr:first-child td:last-child a').click()
            a = self.by_css('.release-download')
            self.assertEqual(NEWS_ARCHIVE_URL, a.get_attribute('href'))

        def upload_app(el):
            self._upload_app(NEWS_ARCHIVE_URL, NEWS_ARCHIVE_SIGNATURE)
            self.wait_for('.global-success-msg', check_app_version_page)

        # this signature is secret so ignore cert checks here
        with self.settings(VALIDATE_CERTIFICATES=False):
            self._register_app(NEWS_CERT, 'test')

        # and run them for uploading the app archive
        with self.settings(VALIDATE_CERTIFICATES=True):
            self.wait_for('.global-success-msg', upload_app)

    def _upload_app(self, url, sig):
        self.go_to_app_upload()
        self.by_id('id_download').send_keys(url)
        self.by_id('id_signature').send_keys(sig)
        self.by_id('submit').click()

    def _register_app(self, cert, sig):
        self.go_to_app_register()
{'fraction_non_alphanumeric': 0.10986001217285453, 'fraction_numerical': 0.00426049908703591, 'mean_word_length': 2.6685267857142856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3133258', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1037, 'n_words': 170}