Exemple #1
0
    def test_parse_popcorn_success(self):
        self.assertEqual(
            System.query.filter_by(sys_hwuuid='TEST_SYSID').count(), 0)
        self.assertEqual(SubmissionPackage.query.all(), [])

        subm_text = ("POPCORN 0.1 openSUSE 12.1 i586 TEST_SYSID\n"
                     "v python 2.5 1.1 None x86_64 http://repo.url\n"
                     "o python-lint 1.1 1 None noarch http://repo.url\n")
        parse_text(subm_text)

        sys = System.query.filter_by(sys_hwuuid='TEST_SYSID').one()

        sub = Submission.query.order_by('-sub_id').first()

        self.assertEqual(len(sub.submission_packages), 2)
        self.assertEqual(SubmissionPackage.query.count(), 2)
        self.assertEqual(Vendor.query.first().vendor_name, "http://repo.url")

        p1 = SubmissionPackage.query.filter_by(pkg_name="python").one()
        self.assertEqual(p1.pkg_name, "python")
        self.assertEqual(p1.pkg_version, "2.5")
        self.assertEqual(p1.pkg_release, "1.1")
        self.assertEqual(p1.pkg_epoch, "")
        self.assertEqual(p1.pkg_arch, "x86_64")
        self.assertEqual(p1.pkg_status, "voted")
Exemple #2
0
    def test_parse_popcorn_success(self):
        self.assertEqual(System.query.filter_by(sys_hwuuid='TEST_HW_UUID'
                                                ).count(), 0)
        self.assertEqual(SubmissionPackage.query.all(), [])
        subm_text = ("POPCORN 0.1 openSUSE 12.1 i586 TEST_HW_UUID\n"
                     "v python 2.5 1.1 None x86_64 http://repo.url\n"
                     "o python-lint 1.1 1 None noarch http://repo.url\n")
        parse_text(subm_text)

        system = System.query.filter_by(sys_hwuuid='TEST_HW_UUID').one()
        
        self.assertEqual(len(system.submissions), 1)

        sub = system.last_submission
        self.assertEqual(len(sub.submission_packages), 2)
        self.assertEqual(SubmissionPackage.query.count(), 2)
        self.assertEqual(Vendor.query.first().vendor_name, "http://repo.url")

        p1 = SubmissionPackage.query.filter_by(pkg_name="python").one()
        self.assertEqual(p1.pkg_name, "python")
        self.assertEqual(p1.pkg_version, "2.5")
        self.assertEqual(p1.pkg_release, "1.1")
        self.assertEqual(p1.pkg_epoch, "")
        self.assertEqual(p1.pkg_arch, "x86_64")
        self.assertEqual(p1.pkg_status, "voted")
Exemple #3
0
    def test_parse_no_early_submission_error(self):
        sys = System("TEST_HWUUID", date.today() - timedelta(days=300))
        self.db_session.add(sys)
        self.db_session.commit()

        sub = "POPCORN 0.1 openSUSE 11.4 x86_64 %s\n" % sys.sys_hwuuid
        parse_text(sub)

        self.assertEqual(sys.last_sub_date, date.today())
Exemple #4
0
    def test_parse_no_early_submission_error(self):
        sys = System("TEST_HWUUID", date.today() - timedelta(days=300))
        self.db_session.add(sys)
        self.db_session.commit()

        sub = "POPCORN 0.1 openSUSE 11.4 x86_64 %s\n" % sys.sys_hwuuid
        parse_text(sub)

        self.assertEqual(sys.last_sub_date, date.today())
Exemple #5
0
    def test_parse_distro_doesnt_exist_gets_created(self):
        self.assertRaises(NoResultFound,
                          Distro.query.filter_by(distro_name="new_Distro").one)

        parse_text("POPCORN 0.1 Distroxillix 1.0 x86_64 some_hwwuid\n")

        distro = Distro.query.filter_by(distro_name="Distroxillix").one()

        self.assertEqual("Distroxillix", distro.distro_name)
        self.assertEqual("1.0", distro.distro_version)
Exemple #6
0
    def test_parse_distro_doesnt_exist_gets_created(self):
        self.assertRaises(NoResultFound,
                          Distro.query.filter_by(distro_name="new_Distro").one)

        parse_text("POPCORN 0.1 Distroxillix 1.0 x86_64 some_hwwuid\n")

        distro = Distro.query.filter_by(distro_name="Distroxillix").one()

        self.assertEqual("Distroxillix", distro.distro_name)
        self.assertEqual("1.0", distro.distro_version)
Exemple #7
0
def receive_submission():
    f = request.files['popcorn']
    if request.headers.get('Content-Encoding') == 'gzip':
        with gzip.GzipFile(fileobj=f, mode='rb') as g:
            try:
                submission = g.read()
            except IOError:
                submission = f.read()
    else:
        submission = f.read()
    try:
        parse_text(submission)
    except (EarlySubmissionError, FormatError), e:
        return str(e)
Exemple #8
0
def receive_submission():
    f = request.files['popcorn']
    if request.headers.get('Content-Encoding') == 'gzip':
        with gzip.GzipFile(fileobj=f, mode='rb') as g:
            try:
                submission = g.read()
            except IOError:
                submission = f.read()
    else:
        submission = f.read()
    try:
        parse_text(submission)
    except (EarlySubmissionError, FormatError), e:
        return str(e)
Exemple #9
0
	def test_mail_call(self):
		with mock.patch('popcorn.parse.mail_to_admin') as patched:
			parse_text(parse_data)
			patched.assert_called_with(DataError)