Ejemplo n.º 1
0
def run():
    from mod_home.models import CCExtractorVersion, GeneralData
    from mod_regression.models import Category, RegressionTest, InputType, OutputType, RegressionTestOutput
    from mod_sample.models import Sample
    from mod_upload.models import Upload
    from mod_auth.models import User
    from database import create_session

    db = create_session(sys.argv[1])

    entries = []
    categories = [
        Category('Broken', 'Samples that are broken'),
        Category('DVB', 'Samples that contain DVB subtitles'),
        Category('DVD', 'Samples that contain DVD subtitles'),
        Category('MP4', 'Samples that are stored in the MP4 format'),
        Category('General', 'General regression samples')
    ]
    entries.extend(categories)

    samples = [
        Sample('sample1', 'ts', 'sample1'),
        Sample('sample2', 'ts', 'sample2')
    ]
    entries.extend(samples)

    cc_version = CCExtractorVersion(
        '0.84', '2016-12-16T00:00:00Z',
        '77da2dc873cc25dbf606a3b04172aa9fb1370f32')
    entries.append(cc_version)

    regression_tests = [
        RegressionTest(1, '-autoprogram -out=ttxt -latin1', InputType.file,
                       OutputType.file, 3, 10),
        RegressionTest(2, '-autoprogram -out=ttxt -latin1 -ucla',
                       InputType.file, OutputType.file, 1, 10)
    ]
    entries.extend(regression_tests)

    gen_data = GeneralData('last_commit',
                           '71dffd6eb30c1f4b5cf800307de845072ce33262')
    entries.append(gen_data)

    regression_test_output = [
        RegressionTestOutput(1, "test1", "srt", "test1.srt"),
        RegressionTestOutput(2, "test2", "srt", "test2.srt")
    ]
    entries.extend(regression_test_output)

    for entry in entries:
        try:
            db.add(entry)
            db.commit()
        except IntegrityError:
            print("Entry already exists!", entry, flush=True)
            db.rollback()
Ejemplo n.º 2
0
def run():
    from mod_home.models import CCExtractorVersion, GeneralData
    from mod_regression.models import Category, RegressionTest, InputType, \
        OutputType
    from mod_sample.models import Sample
    from mod_upload.models import Upload
    from mod_auth.models import User
    from database import create_session

    db = create_session(sys.argv[1])

    categories = [
        Category('Broken', 'Samples that are broken'),
        Category('DVB', 'Samples that contain DVB subtitles'),
        Category('DVD', 'Samples that contain DVD subtitles'),
        Category('MP4', 'Samples that are stored in the MP4 format'),
        Category('General', 'General regression samples')
    ]
    db.add_all(categories)
    db.commit()

    samples = [
        Sample('sample1', 'ts', 'sample1'),
        Sample('sample2', 'ts', 'sample2')
    ]
    db.add_all(samples)
    db.commit()

    cc_version = CCExtractorVersion(
        '0.84', '2016-12-16', '77da2dc873cc25dbf606a3b04172aa9fb1370f32'
    )
    db.add(cc_version)
    db.commit()

    regression_tests = [
        RegressionTest(
            1, '-autoprogram -out=ttxt -latin1', InputType.file,
            OutputType.file, 3, 10),
        RegressionTest(
            2, '-autoprogram -out=ttxt -latin1 -ucla', InputType.file,
            OutputType.file, 1, 10)
    ]
    db.add_all(regression_tests)
    db.commit()

    gen_data = GeneralData(
        'last_commit', '71dffd6eb30c1f4b5cf800307de845072ce33262')
    db.add(gen_data)
    db.commit()
Ejemplo n.º 3
0
    def test_edit_category_empty(self):
        """
        Check it won't edit a category with an empty name
        """
        self.create_user_with_role(self.user.name, self.user.email,
                                   self.user.password, Role.admin)

        with self.app.test_client() as c:
            c.post('/account/login',
                   data=self.create_login_form_data(self.user.email,
                                                    self.user.password))
            new_category = Category(name="C-137",
                                    description="Wubba lubba dub dub")
            g.db.add(new_category)
            g.db.commit()
            c.post('/regression/category/1/edit',
                   data=dict(category_name="",
                             category_description="GG",
                             submit=True))
            self.assertEqual(
                Category.query.filter(Category.name == "").first(), None)
            self.assertEqual(
                Category.query.filter(Category.description == "GG").first(),
                None)
            self.assertNotEqual(
                Category.query.filter(Category.name == "C-137").first(), None)
Ejemplo n.º 4
0
def category_add():
    """
    Function to add a regression test category
    """
    form = AddCategoryForm(request.form)
    if form.validate():
        new_category = Category(name=form.category_name.data,
                                description=form.category_description.data)
        g.db.add(new_category)
        g.db.commit()
        flash('New Category Added')
        return redirect(url_for('.index'))
    return {'form': form}
Ejemplo n.º 5
0
    def test_edit_wrong_category(self):
        """
        Check it will throw 404 if trying to edit a category which doesn't exist
        """
        self.create_user_with_role(self.user.name, self.user.email, self.user.password, Role.admin)

        with self.app.test_client() as c:
            c.post('/account/login', data=self.create_login_form_data(self.user.email, self.user.password))
            new_category = Category(name="C-137", description="Wubba lubba dub dub")
            g.db.add(new_category)
            g.db.commit()
            response = c.post(
                'regression/category/1729/edit',
                data=dict(category_name="Sheldon", category_description="That's my spot", submit=True)
            )
            self.assertEqual(response.status_code, 404)
Ejemplo n.º 6
0
 def test_edit_category(self):
     """
     Check it will edit a category
     """
     self.create_user_with_role(self.user.name, self.user.email,
                                self.user.password, Role.admin)
     with self.app.test_client() as c:
         response = c.post('/account/login',
                           data=self.create_login_form_data(
                               self.user.email, self.user.password))
         new_category = Category(name="C-137",
                                 description="Wubba lubba dub dub")
         g.db.add(new_category)
         g.db.commit()
         response = c.post('/regression/category/1/edit',
                           data=dict(category_name="Sheldon",
                                     category_description="That's my spot",
                                     submit=True))
         self.assertNotEqual(
             Category.query.filter(Category.name == "Sheldon").first(),
             None)
Ejemplo n.º 7
0
    def setUp(self):
        self.app.preprocess_request()
        g.db = create_session(self.app.config['DATABASE_URI'],
                              drop_tables=True)
        # enable Foreign keys for unit tests
        g.db.execute('pragma foreign_keys=on')

        general_data = [
            GeneralData('last_commit',
                        "1978060bf7d2edd119736ba3ba88341f3bec3323"),
            GeneralData(f'fetch_commit_{TestPlatform.linux.value}',
                        "1978060bf7d2edd119736ba3ba88341f3bec3323"),
            GeneralData(f'fetch_commit_{TestPlatform.windows.value}',
                        "1978060bf7d2edd119736ba3ba88341f3bec3323")
        ]
        g.db.add_all(general_data)

        self.ccextractor_version = CCExtractorVersion(
            "1.2.3", "2013-02-27T19:35:32Z",
            "1978060bf7d2edd119736ba3ba88341f3bec3323")
        g.db.add(self.ccextractor_version)

        fork = Fork(
            f"https://github.com/{g.github['repository_owner']}/{g.github['repository']}.git"
        )
        g.db.add(fork)
        g.db.commit()

        dummy_user = User(signup_information['existing_user_name'],
                          signup_information['existing_user_role'],
                          signup_information['existing_user_email'],
                          signup_information['existing_user_pwd'])
        g.db.add(dummy_user)
        g.db.commit()

        test = [
            Test(TestPlatform.linux, TestType.pull_request, 1, "master",
                 "1978060bf7d2edd119736ba3ba88341f3bec3323", 1),
            Test(TestPlatform.linux, TestType.pull_request, 1, "master",
                 "abcdefgh", 1)
        ]
        g.db.add_all(test)
        g.db.commit()

        categories = [
            Category("Broken", "Samples that are broken"),
            Category("DVB", "Samples that contain DVB subtitles"),
            Category("DVD", "Samples that contain DVD subtitles"),
            Category("MP4", "Samples that are stored in the MP4 format"),
            Category("General", "General regression samples")
        ]
        g.db.add_all(categories)
        g.db.commit()

        samples = [
            Sample("sample1", "ts", "sample1"),
            Sample("sample2", "ts", "sample2")
        ]
        g.db.add_all(samples)
        g.db.commit()

        upload = [
            Upload(1, 1, 1, Platform.windows),
            Upload(1, 2, 1, Platform.linux)
        ]
        g.db.add_all(upload)
        g.db.commit()

        regression_tests = [
            RegressionTest(1, "-autoprogram -out=ttxt -latin1 -2",
                           InputType.file, OutputType.file, 3, 10),
            RegressionTest(2, "-autoprogram -out=ttxt -latin1 -ucla",
                           InputType.file, OutputType.file, 1, 10)
        ]
        g.db.add_all(regression_tests)
        g.db.commit()

        categories[0].regression_tests.append(regression_tests[0])
        categories[2].regression_tests.append(regression_tests[1])
        regression_test_outputs = [
            RegressionTestOutput(1, "sample_out1", ".srt", ""),
            RegressionTestOutput(2, "sample_out2", ".srt", "")
        ]
        g.db.add_all(regression_test_outputs)
        g.db.commit()

        rtof = RegressionTestOutputFiles("bluedabadee", 2)
        g.db.add(rtof)
        g.db.commit()

        test_result_progress = [
            TestProgress(1, TestStatus.preparation, "Test 1 preparation"),
            TestProgress(1, TestStatus.building, "Test 1 building"),
            TestProgress(1, TestStatus.testing, "Test 1 testing"),
            TestProgress(1, TestStatus.completed, "Test 1 completed"),
            TestProgress(2, TestStatus.preparation, "Test 2 preparation"),
            TestProgress(2, TestStatus.building, "Test 2 building"),
            TestProgress(2, TestStatus.testing, "Test 2 testing"),
            TestProgress(2, TestStatus.completed, "Test 2 completed")
        ]
        g.db.add_all(test_result_progress)
        g.db.commit()

        test_results = [
            TestResult(1, 1, 200, 0, 0),
            TestResult(1, 2, 601, 0, 0),
            TestResult(2, 1, 200, 200, 0),
            TestResult(2, 2, 601, 0, 0)
        ]
        g.db.add_all(test_results)
        g.db.commit()

        test_result_files = [
            TestResultFile(1, 1, 1, "sample_out1"),
            TestResultFile(1, 2, 2, "sample_out2"),
            TestResultFile(2, 1, 1, "sample_out1"),
            TestResultFile(2, 2, 2, "sample_out2", "out2")
        ]
        g.db.add_all(test_result_files)
        g.db.commit()

        forbidden_mime = ForbiddenMimeType("application/javascript")
        forbidden_ext = [ForbiddenExtension("js"), ForbiddenExtension("com")]
        g.db.add(forbidden_mime)
        g.db.add_all(forbidden_ext)
        g.db.commit()
Ejemplo n.º 8
0
 def setUp(self):
     self.app.preprocess_request()
     g.db = create_session(self.app.config['DATABASE_URI'],
                           drop_tables=True)
     g.db.execute('pragma foreign_keys=on')  # Enable Foreign for unit tests
     commit_name_linux = 'fetch_commit_' + TestPlatform.linux.value
     commit_name_windows = 'fetch_commit_' + TestPlatform.windows.value
     general_data = [
         GeneralData('last_commit',
                     '1978060bf7d2edd119736ba3ba88341f3bec3323'),
         GeneralData(commit_name_linux,
                     '1978060bf7d2edd119736ba3ba88341f3bec3323'),
         GeneralData(commit_name_windows,
                     '1978060bf7d2edd119736ba3ba88341f3bec3323')
     ]
     g.db.add_all(general_data)
     self.ccextractor_version = CCExtractorVersion(
         '1.2.3', '2013-02-27T19:35:32Z',
         '1978060bf7d2edd119736ba3ba88341f3bec3323')
     g.db.add(self.ccextractor_version)
     fork_url = ('https://github.com/{user}/{repo}.git').format(
         user=g.github['repository_owner'], repo=g.github['repository'])
     fork = Fork(fork_url)
     g.db.add(fork)
     g.db.commit()
     dummy_user = User(signup_information['existing_user_name'],
                       signup_information['existing_user_role'],
                       signup_information['existing_user_email'],
                       signup_information['existing_user_pwd'])
     g.db.add(dummy_user)
     g.db.commit()
     test = [
         Test(TestPlatform.linux, TestType.pull_request, 1, 'master',
              '1978060bf7d2edd119736ba3ba88341f3bec3323', 1),
         Test(TestPlatform.linux, TestType.pull_request, 1, 'master',
              'abcdefgh', 1)
     ]
     g.db.add_all(test)
     g.db.commit()
     categories = [
         Category('Broken', 'Samples that are broken'),
         Category('DVB', 'Samples that contain DVB subtitles'),
         Category('DVD', 'Samples that contain DVD subtitles'),
         Category('MP4', 'Samples that are stored in the MP4 format'),
         Category('General', 'General regression samples')
     ]
     g.db.add_all(categories)
     g.db.commit()
     samples = [
         Sample('sample1', 'ts', 'sample1'),
         Sample('sample2', 'ts', 'sample2')
     ]
     g.db.add_all(samples)
     g.db.commit()
     upload = [
         Upload(1, 1, 1, Platform.windows),
         Upload(1, 2, 1, Platform.linux)
     ]
     g.db.add_all(upload)
     g.db.commit()
     regression_tests = [
         RegressionTest(1, '-autoprogram -out=ttxt -latin1 -2',
                        InputType.file, OutputType.file, 3, 10),
         RegressionTest(2, '-autoprogram -out=ttxt -latin1 -ucla',
                        InputType.file, OutputType.file, 1, 10)
     ]
     g.db.add_all(regression_tests)
     g.db.commit()
     categories[0].regression_tests.append(regression_tests[0])
     categories[2].regression_tests.append(regression_tests[1])
     regression_test_outputs = [
         RegressionTestOutput(1, 'sample_out1', '.srt', ''),
         RegressionTestOutput(2, 'sample_out2', '.srt', '')
     ]
     g.db.add_all(regression_test_outputs)
     g.db.commit()
     test_result_progress = [
         TestProgress(1, TestStatus.preparation, "Test 1 preperation"),
         TestProgress(1, TestStatus.building, "Test 1 building"),
         TestProgress(1, TestStatus.testing, "Test 1 testing"),
         TestProgress(1, TestStatus.completed, "Test 1 completed"),
         TestProgress(2, TestStatus.preparation, "Test 2 preperation"),
         TestProgress(2, TestStatus.building, "Test 2 building"),
         TestProgress(2, TestStatus.testing, "Test 2 testing"),
         TestProgress(2, TestStatus.completed, "Test 2 completed")
     ]
     g.db.add_all(test_result_progress)
     g.db.commit()
     test_results = [
         TestResult(1, 1, 200, 0, 0),
         TestResult(1, 2, 601, 0, 0),
         TestResult(2, 1, 200, 200, 0),
         TestResult(2, 2, 601, 0, 0)
     ]
     g.db.add_all(test_results)
     g.db.commit()
     test_result_files = [
         TestResultFile(1, 1, 1, 'sample_out1'),
         TestResultFile(1, 2, 2, 'sample_out2'),
         TestResultFile(2, 1, 1, 'sample_out1'),
         TestResultFile(2, 2, 2, 'sample_out2', 'out2')
     ]
     g.db.add_all(test_result_files)
     g.db.commit()
     forbidden_mime = ForbiddenMimeType('application/javascript')
     forbidden_ext = [ForbiddenExtension('js'), ForbiddenExtension('com')]
     g.db.add(forbidden_mime)
     g.db.add_all(forbidden_ext)
     g.db.commit()