Beispiel #1
0
    def test_sections(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        data = os.path.abspath(os.path.dirname(__file__))
        data = os.path.join(data, "data")
        repo = ProjectsRepository(data)
        if len(repo.Groups) != 2:
            for f in repo.Groups:
                fLOG(f)
            self.assertEqual(len(repo.Groups), 2)
        gr = repo.Groups[0]
        sections = repo.get_sections(gr)
        names = [k for k in sorted(sections)]
        assert names == [
            '', 'extrait', 'next', 'pitch', 'programme', 'rapport', 'title'
        ]
        #for k,v in sections.items(): fLOG(k,v)
        if sections["next"] != ['', '* module tweepy', '']:
            raise Exception(sections["next"])
        if sections["extrait"] != [
                '', '::', '', '    paragraphe 1', '', '    paragraphe 2', ''
        ]:
            raise Exception(sections["extrait"])
    def test_sections(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        data = os.path.abspath(os.path.dirname(__file__))
        data = os.path.join(data, "data")
        repo = ProjectsRepository(data)
        if len(repo.Groups) != 2:
            for f in repo.Groups:
                fLOG(f)
            self.assertEqual(len(repo.Groups), 2)
        groups = list(sorted(repo.Groups))
        gr = groups[0]
        if gr is None or len(gr) < 2:
            raise Exception("Empty group '{0}'".format(gr))
        self.assertEqual(gr, 'group_el1')
        sections = repo.get_sections(gr)
        names = [k for k in sorted(sections)]
        self.assertEqual(
            names,
            ['', 'extrait', 'next', 'pitch', 'programme', 'rapport', 'title'])
        if sections["next"] != ['', '* module tweepy', '']:
            raise Exception(sections["next"])
        if sections["extrait"] != [
                '', '::', '', '    paragraphe 1', '', '    paragraphe 2', ''
        ]:
            raise Exception(sections["extrait"])
Beispiel #3
0
    def test_emails(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        data = os.path.abspath(os.path.dirname(__file__))
        data = os.path.join(data, "data")
        repo = ProjectsRepository(data)
        self.assertEqual(len(repo.Groups), 2)
        gr = repo.Groups[0]
        emails = repo.get_emails(gr)
        fLOG(emails)
        self.assertEqual(emails, ['*****@*****.**',
                                  'name.lastname@something', '*****@*****.**', 'name.lastname@something'])
Beispiel #4
0
    def test_emails(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        data = os.path.abspath(os.path.dirname(__file__))
        data = os.path.join(data, "data")
        repo = ProjectsRepository(data)
        self.assertEqual(len(repo.Groups), 2)
        gr = repo.Groups[0]
        emails = repo.get_emails(gr)
        fLOG(emails)
        self.assertEqual(emails, [
            '*****@*****.**', 'name.lastname@something',
            '*****@*****.**', 'name.lastname@something'
        ])
    def test_emails(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        data = os.path.abspath(os.path.dirname(__file__))
        data = os.path.join(data, "data")
        repo = ProjectsRepository(data)
        self.assertEqual(len(repo.Groups), 2)
        groups = list(sorted(repo.Groups))
        gr = groups[0]
        if gr is None or len(gr) < 2:
            raise Exception("Empty group '{0}'".format(gr))
        self.assertEqual(gr, 'group_el1')
        emails = repo.get_emails(gr)
        self.assertEqual(emails, [
            '*****@*****.**', 'name.lastname@something',
            '*****@*****.**', 'name.lastname@something'
        ])
Beispiel #6
0
    def test_sections(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        data = os.path.abspath(os.path.dirname(__file__))
        data = os.path.join(data, "data")
        repo = ProjectsRepository(data)
        if len(repo.Groups) != 2:
            for f in repo.Groups:
                fLOG(f)
            self.assertEqual(len(repo.Groups), 2)
        gr = repo.Groups[0]
        sections = repo.get_sections(gr)
        names = [k for k in sorted(sections)]
        assert names == [
            '', 'extrait', 'next', 'pitch', 'programme', 'rapport', 'title']
        #for k,v in sections.items(): fLOG(k,v)
        if sections["next"] != ['', '* module tweepy', '']:
            raise Exception(sections["next"])
        if sections["extrait"] != ['', '::', '', '    paragraphe 1', '', '    paragraphe 2', '']:
            raise Exception(sections["extrait"])
Beispiel #7
0
    def test_sections(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        data = os.path.abspath(os.path.dirname(__file__))
        data = os.path.join(data, "data")
        dfile = os.path.join(data, "notes_eleves_2104_2015.xlsx")
        df = pandas.read_excel(dfile, skiprows=5)
        df = df[df["Groupe"] != "moyenne"].copy()
        fLOG(df.columns)
        fLOG(df.tail())
        fLOG(df.shape)
        emails = [
            "*****@*****.**".lower(),
            "*****@*****.**"
        ]
        temp = get_temp_folder(__file__, "temp_repository")
        try:
            proj = ProjectsRepository.create_folders_from_dataframe(
                df,
                temp,
                col_subject="sujet",
                fLOG=fLOG,
                col_group=None,
                col_student="Eleves",
                col_mail=None,
                email_function=emails,
                skip_if_nomail=True)
        except ProjectsRepository.MailNotFound:
            pass

        emails = [
            "*****@*****.**".lower(), "*****@*****.**",
            "*****@*****.**"
        ]

        proj = ProjectsRepository.create_folders_from_dataframe(
            df,
            temp,
            col_subject="sujet",
            fLOG=fLOG,
            col_group=None,
            col_student="Eleves",
            col_mail=None,
            email_function=emails,
            must_have_email=False)

        do_test = True
        if do_test:
            data = os.path.abspath(
                os.path.join(os.path.dirname(__file__), "data"))
            box = MailBoxMock(data, b"unittestunittest", fLOG)
            box.login()

            email_render = EmailMessageRenderer(tmpl=template_email_html_short,
                                                fLOG=fLOG)
            render = EmailMessageListRenderer(title="list of mails",
                                              email_renderer=email_render,
                                              fLOG=fLOG)

            mails = proj.dump_group_mails(render,
                                          group=None,
                                          mailbox=box,
                                          subfolder="trav",
                                          date=datetime.datetime(2015, 1, 9))

            box.logout()

        suivi = os.path.join(temp, "ABOUT.firstname", "suivi.rst")
        with open(suivi, "r", encoding="utf8") as f:
            content = f.read()
        self.assertIn("* mails: [email protected]", content)

        self.assertEqual(len(proj.Groups), 3)
        mails = proj.get_emails(proj.Groups[0])
        self.assertEqual(len(mails), 1)
        self.assertIn(mails[0], emails)
        fLOG("------", os.path.exists(os.path.join(temp, "mail_style.css")))
        proj.write_summary()
        fLOG("------")
        files = [
            os.path.join(temp, "index.html"),
            os.path.join(
                temp, "ABOUT.firstname",
                "d_2015-08-01_p_noreply-at-voyages-sncf-com_ii_8de6a63addb7c03407bc6f0caabd967e.html"
            ),
            os.path.join(temp, "mail_style.css")
        ]
        nb = 0
        for name in files:
            if not os.path.exists(name):
                raise FileNotFoundError(name)
            nb += 1
            with open(name, "r", encoding="utf8") as f:
                content = f.read()
            self.assertNotIn("ut_automation_students", content)
        self.assertEqual(nb, len(files))
Beispiel #8
0
    def test_sections(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        data = os.path.abspath(os.path.dirname(__file__))
        data = os.path.join(data, "data")
        dfile = os.path.join(data, "notes_eleves_2104_2015.xlsx")
        df = pandas.read_excel(dfile, skiprows=5)
        df = df[df["Groupe"] != "moyenne"].copy()
        fLOG(df.columns)
        fLOG(df.tail())
        fLOG(df.shape)
        emails = ["*****@*****.**".lower(),
                  "*****@*****.**"]
        temp = get_temp_folder(__file__, "temp_repository")
        try:
            proj = ProjectsRepository.create_folders_from_dataframe(df, temp, col_subject="sujet",
                                                                    fLOG=fLOG, col_group=None,
                                                                    email_function=emails,
                                                                    skip_if_nomail=True)
        except ProjectsRepository.MailNotFound:
            pass

        emails = ["*****@*****.**".lower(), "*****@*****.**",
                  "*****@*****.**"]

        proj = ProjectsRepository.create_folders_from_dataframe(df, temp, col_subject="sujet",
                                                                fLOG=fLOG, col_group=None,
                                                                email_function=emails,
                                                                must_have_email=False)

        if True:
            data = os.path.abspath(os.path.join(
                os.path.dirname(__file__), "data"))
            box = MailBoxMock(data, b"unittestunittest", fLOG)
            box.login()

            email_render = EmailMessageRenderer(
                tmpl=template_email_html_short, fLOG=fLOG)
            render = EmailMessageListRenderer(title="list of mails",
                                              email_renderer=email_render, fLOG=fLOG)

            mails = proj.dump_group_mails(render, group=None,
                                          mailbox=box, subfolder="trav",
                                          date=datetime.datetime(2015, 1, 9))

            box.logout()

        suivi = os.path.join(temp, "ABOUT.firstname", "suivi.rst")
        with open(suivi, "r", encoding="utf8") as f:
            content = f.read()
        self.assertIn("* mails: [email protected]", content)

        self.assertEqual(len(proj.Groups), 3)
        mails = proj.get_emails(proj.Groups[0])
        self.assertEqual(mails, ['*****@*****.**'])
        fLOG("------", os.path.exists(os.path.join(temp, "mail_style.css")))
        proj.write_summary()
        fLOG("------")
        files = [os.path.join(temp, "index.html"),
                 os.path.join(
                     temp, "ABOUT.firstname", "d_2015-08-01_p_noreply-at-voyages-sncf-com_ii_8de6a63addb7c03407bc6f0caabd967e.html"),
                 os.path.join(temp, "mail_style.css")]
        nb = 0
        for name in files:
            if not os.path.exists(name):
                raise FileNotFoundError(name)
            nb += 1
            with open(name, "r", encoding="utf8") as f:
                content = f.read()
            self.assertNotIn("ut_automation_students", content)
        self.assertEqual(nb, len(files))