Exemplo n.º 1
0
    def test_databaseExitIfownerNameIsEmpty_assertFalse(self):
        huge_str = ''
        for i in range(150):
            huge_str += '#'

        db = SqliteDB()
        with self.assertRaises(SystemExit):
            db.add_dependency("Some_repo", "v0.0.2", "e45d87", huge_str)
Exemplo n.º 2
0
        options.add_mail_address(args["mail"][0])

    if args["time"]:
        global LATENCY
        LATENCY = args["time"][0]

    if args["verbose"]:
        global verbose
        verbose = True


if __name__ == '__main__':
    mail_service = Mailing()
    parse_args(mail_service)

    db = SqliteDB()
    is_db_filled = bool(db.get_used_versions())
    db.close_db()

    if not is_db_filled:
        exit("Please, fill the database before running novigrad")

    s = scheduler(time, sleep)
    if verbose:
        print('\nVerbose mode launched,'
              '\nReport will be generated on '
              'etc/reports.txt in ' + str(LATENCY) + ' seconds\n')
        s.enter(LATENCY, 1, check_dependencies_and_print)
    else:
        s.enter(LATENCY, 1, check_dependencies_and_report, mail_service)
Exemplo n.º 3
0
 def __init__(self):
     self._base_url = "https://api.github.com/repos/"
     self._db = SqliteDB()
Exemplo n.º 4
0
    def generate_pdf(self, values: dict):
        """Generate PDF

        Check Dependencies
        Then order them 
        Finally create pdf report
        """
        db = SqliteDB()
        db_content = db.get_used_versions()
        db.close_db()

        _text = []

        _title = " - Dependencies Report - "
        _text.append(Paragraph(_title, self._styles_title))
        _text.append(Paragraph(self._formatted_time, self._styles_title))

        if bool(values):
            _text.append(
                Paragraph("UP TO DATE : ", self._styles_alert_uptodate))

            for _name in values:
                if (values[_name][0] == db_content[_name][0]
                    or values[_name][0] == 'Missing') \
                        and values[_name][1] == db_content[_name][1]:
                    _newest = _name + \
                              " : " + \
                              values[_name][0] + \
                              " - " + \
                              values[_name][1]

                    _text.append(Paragraph(_newest, self._styles_default))
                    _text.append(Paragraph("", self._styles_space))

            _text.append(
                Paragraph("NEW COMMIT AVAILABLE : ",
                          self._styles_alert_commit))

            for _name in values:
                if values[_name][1] != db_content[_name][1]:
                    _newest = _name + \
                              " : " + \
                              'https://github.com/' + \
                              db_content[_name][2] + \
                              '/' + _name + \
                              " " + \
                              values[_name][0] + \
                              " - " + \
                              values[_name][1]

                    _text.append(Paragraph(_newest, self._styles_default))
                    _text.append(Paragraph("", self._styles_space))

            _text.append(
                Paragraph("NEW RELEASE AVAILABLE : ",
                          self._styles_alert_release))

            for _name in values:
                if values[_name][0] != db_content[_name][0] \
                        and values[_name][0] != 'Missing':
                    _newest = _name + \
                              " : " + \
                              'https://github.com/' + \
                              db_content[_name][2] + \
                              '/' + _name + \
                              " - " + values[_name][0] + \
                              " - " + values[_name][1]

                    _text.append(Paragraph(_newest, self._styles_default))
                    _text.append(Paragraph("", self._styles_space))

        else:
            exit("Novigrad encountered an error checking, " +
                 "whether the database is non-empty.")

        self._doc_param.build(_text)
Exemplo n.º 5
0
 def test_databaseCantOpenWrongDataBase_assertFalse(self):
     with self.assertRaises(SystemExit):
         SqliteDB("test/sql/unknown_db.db")
Exemplo n.º 6
0
 def test_databaseExitIfownerNameIsEmpty_assertFalse(self):
     db = SqliteDB()
     with self.assertRaises(SystemExit):
         db.add_dependency("Some_repo", "v0.0.2", "e45d87", "")
Exemplo n.º 7
0
 def test_databaseExitIfNoRepositoryExists_assertFalse(self):
     db = SqliteDB()
     with self.assertRaises(SystemExit):
         db.get_repo_owner("some_imaginary_repository")
Exemplo n.º 8
0
 def test_databaseCanConnectToTheDefaultDataBase_assertTrue(self):
     try:
         db = SqliteDB()
         db.close_db()
     except Exception:
         self.assertEqual(True, False)