Example #1
0
class test_CertificateDataLoder(unittest.TestCase):
    def setUp(self):
        self.allCertificates = AllCertificates()
        self.certificateDataLoder = CertificateDataLoder()

    def test_CertificateLoading(self):

        self.f = open('names.csv', "w")
        self.f.write("No,First Name ,Second Name, email" + "\n")
        self.f.write("1 ,ranjith, tharayil ,[email protected]" + "\n")
        self.f.write("2 ,anju, M dominic ,[email protected]" + "\n")
        self.f.close()
        certificates = self.allCertificates.getAllCertificates()
        self.certificateDataLoder = self.certificateDataLoder.load(
            certificates, 'names.csv', True)
        self.assertEqual(2, len(certificates))

    def test_CertificateLoadingNoEmail(self):

        self.f = open('names.csv', "w")
        self.f.write("No,First Name ,Second Name" + "\n")
        self.f.write("1 ,ranjith, tharayil " + "\n")
        self.f.write("2 ,anju, M dominic " + "\n")
        self.f.write("2 ,anju, M dominic " + "\n")
        self.f.close()
        certificates = self.allCertificates.getAllCertificates()
        self.certificateDataLoder = self.certificateDataLoder.load(
            certificates, 'names.csv', False)
        self.assertEqual(3, len(certificates))

    def test_CertificateLoadingDataCheckWithEmail(self):

        self.f = open('names.csv', "w")
        self.f.write("No,First Name ,Second Name, email" + "\n")
        self.f.write("1 ,Ranjith, Tharayil ,[email protected]" + "\n")
        self.f.close()
        certificates = self.allCertificates.getAllCertificates()
        self.certificateDataLoder = self.certificateDataLoder.load(
            certificates, 'names.csv', True)
        for c in certificates:
            self.assertEqual('Ranjith Tharayil', c.Name())
            self.assertEqual('*****@*****.**', c.Email())

    def test_CertificateLoadingDataCheckWithNoEmail(self):

        self.f = open('names.csv', "w")
        self.f.write("No,First Name ,Second Name" + "\n")
        self.f.write("1 ,Ranjith, Tharayil " + "\n")
        self.f.close()
        certificates = self.allCertificates.getAllCertificates()
        self.certificateDataLoder = self.certificateDataLoder.load(
            certificates, 'names.csv', False)
        for c in certificates:
            self.assertEqual('Ranjith Tharayil', c.Name())
class test_IssueCertificate(unittest.TestCase):
    def setUp(self):
        self.allCertificates = AllCertificates()
        self.certificateDataLoder = CertificateDataLoder()
        self.issue = AuthorCertificate()

    def test_Create(self):

        pathToSave = './temp'
        if os.path.isdir(pathToSave):
            shutil.rmtree(pathToSave)

        os.mkdir(pathToSave)
        certificate = Certificate('Rahul', 'Panday', '*****@*****.**')

        certificateFile = self.issue.Create(
            './test/data/template.png', pathToSave,
            'https://certifyme.online/devopsma/', certificate)

        self.assertTrue(os.path.exists(pathToSave + '/' + certificateFile))

    def test_BulkIssue(self):

        pathToSave = './temp'

        self.f = open('names.csv', "w")
        self.f.write("No,First Name ,Second Name" + "\n")
        self.f.write("1 ,Ranjith, Tharayil " + "\n")
        self.f.write("2 ,Anju, M Dominic " + "\n")
        self.f.write("3 ,Suraj, Meaheta " + "\n")
        self.f.close()
        certificates = self.allCertificates.getAllCertificates()
        self.certificateDataLoder = self.certificateDataLoder.load(
            certificates, 'names.csv', False)
        self.issue.setQRCodeLocation(400, 700)
        self.issue.setNameLocation(739, 274)
        self.issue.setQrCodeSize(3)
        self.issue.setNameFont('./res/Font Pack/Ubuntu-B.ttf', 50)
        self.allCertificates.setTemplate(
            './test/data/AgileNCR_Participation.png')
        certificateFile = self.issue.BulkIssue(
            pathToSave, 'https://certifyme.online/devopsma/',
            self.allCertificates)
        path, dirs, files = next(os.walk(pathToSave))
        file_count = len(files)
        self.assertEqual(file_count, len(certificates))

    def test_QRCodeLocation(self):
        self.issue.setQRCodeLocation(1000, 300)
        x, y = self.issue.getQRCodeLocation()
        self.assertEqual(1000, x)
        self.assertEqual(300, y)

    def test_NameLocation(self):
        self.issue.setNameLocation(1001, 301)
        x, y = self.issue.getNameLocation()
        self.assertEqual(1001, x)
        self.assertEqual(301, y)

    def test_setQrCodeSize(self):
        self.issue.setQrCodeSize(5)
        self.assertEqual(5, self.issue.getQRCodeSize())

    def test_setQRCodeColor(self):
        self.issue.setQRCodeColor('black', 'white')
        back_color, front_color = self.issue.getQRCodeColor()
        self.assertEqual('black', back_color)
        self.assertEqual('white', front_color)

    def test_setNameFont(self):
        self.issue.setNameFont('black', 10)
        font, size = self.issue.getNameFont()
        self.assertEqual('black', font)
        self.assertEqual(10, size)
Example #3
0
class test_mdGen(unittest.TestCase):
    def setUp(self):

        self.mdGen = mdGen()

        self.allCertificates = AllCertificates()
        self.certificateDataLoder = CertificateDataLoder()
        self.event = AnEvent()
        self.allCertificates = AllCertificates()
        self.issue = AuthorCertificate()
        self.ad = Advertisement()
        self.configurationLoader = ConfigurationLoader(self.event,
                                                       self.allCertificates,
                                                       self.issue, self.ad)

        self.f = open('config.yaml', "w")
        self.f.write("Program : XP2020" + "\n")
        self.f.write("IssuedBy : Anju M Dominic" + "\n")
        self.f.write("Institution : Quadralogics" + "\n")
        self.f.write("Date : 29 dec 1982" + "\n")
        self.f.write("Text : A write-up about the event" + "\n")
        self.f.write("Template : ./AnuMDominicnew.png" + "\n")
        self.f.write("Logo : ./logo.png" + "\n")
        self.f.write(
            "Message : As your organizations progresses through its DevXOps journey, what are the best practices that successful teams use that you should follow? Discover what separates successful DevXOps teams from those that fail, and learn the next steps to take on your DevXOps journey"
            + "\n")
        self.f.write("Banner : ./banner.png" + "\n")
        self.f.write("CTAMessage : Download our E-Book to learn more" + "\n")
        self.f.write("CTALink : www.q.com" + "\n")
        self.f.write("CTALabel : Dload" + "\n")
        self.f.write("Phone : 898654423" + "\n")
        self.f.write("Email : [email protected]" + "\n")
        self.f.write("WebLink : www.qt.com" + "\n")
        self.f.write("Font : ./res/AngelicaCaroline.ttf" + "\n")
        self.f.write("FontSize : 100" + "\n")
        self.f.write("NameX : 150" + "\n")
        self.f.write("NameY : 160" + "\n")
        self.f.write("QRCodeX : 1500" + "\n")
        self.f.write("QRCodeY : 1600" + "\n")
        self.f.write("QRCodeFrontColor : white" + "\n")
        self.f.write("QRCodeBackColor : black" + "\n")
        self.f.write("QRCodeSize : 10" + "\n")
        self.f.write("EventCode: AgileNCR" + "\n")
        self.f.close()
        self.configurationLoader.loadConfig("config.yaml")

    def test_genMDFile(self):
        pathToSave = './md'

        if os.path.isdir(pathToSave):
            shutil.rmtree(pathToSave)
        os.mkdir(pathToSave)
        certificate = Certificate('Rahul', 'Panday', '*****@*****.**')

        mdFile = self.mdGen.Create(pathToSave,
                                   'https://certifyme.online/devopsma/',
                                   certificate)

        self.assertTrue(os.path.exists(mdFile))

    def test_genMDBulkIssue(self):
        pathToSave = './md'

        self.f = open('names.csv', "w")
        self.f.write("No,First Name ,Second Name" + "\n")
        self.f.write("1 ,ranjith, tharayil " + "\n")
        self.f.write("2 ,anju, M dominic " + "\n")
        self.f.write("3 ,Suraj, Meaheta " + "\n")
        self.f.close()
        certificates = self.allCertificates.getAllCertificates()
        self.certificateDataLoder = self.certificateDataLoder.load(
            certificates, 'names.csv', False)

        certificateFile = self.mdGen.genMDBulkIssue(
            pathToSave, 'https://certifyme.online/devopsma/',
            self.allCertificates)
        path, dirs, files = next(os.walk(pathToSave))
        file_count = len(files)
        self.assertEqual(file_count, len(certificates))

    def test_genDefaults(self):
        pathToSave = './md'

        self.f = open('names.csv', "w")
        self.f.write("No,First Name ,Second Name" + "\n")
        self.f.write("1 ,ranjith, tharayil " + "\n")
        self.f.write("2 ,anju, M dominic " + "\n")
        self.f.write("3 ,Suraj, Meaheta " + "\n")
        self.f.close()
        certificates = self.allCertificates.getAllCertificates()
        self.certificateDataLoder = self.certificateDataLoder.load(
            certificates, 'names.csv', False)

        defaultFile = self.mdGen.genDefaults(pathToSave, self.issue,
                                             self.event, self.ad)
        self.assertTrue(os.path.exists(defaultFile))
Example #4
0
class webPageDataGen:
    """All Certificates """

    # default constructor
    def __init__(self):
        X = 0

    def generate(self, csvCertFile, config):

        pathToSave = './webPageDataGen'

        self.mdGen = mdGen()

        self.allCertificates = AllCertificates()
        self.certificateDataLoder = CertificateDataLoder()
        self.event = AnEvent()
        self.allCertificates = AllCertificates()
        self.issue = AuthorCertificate()
        self.ad = Advertisement()
        self.configurationLoader = ConfigurationLoader(self.event,
                                                       self.allCertificates,
                                                       self.issue, self.ad)

        self.configurationLoader.loadConfig(
            "./test/data//SYNAPSE//config1.yaml")
        certificates = self.allCertificates.getAllCertificates()
        self.certificateDataLoder = self.certificateDataLoder.load(
            certificates, './test/data//SYNAPSE//names.csv', False)

        URL = "https://certifyme.online/CSIT/SYNAPSE/SYNAPSEQA2020/"
        certificateFile = self.issue.BulkIssue(
            pathToSave + "/" + self.event.getEventCode(),
            URL,
            self.allCertificates,
            eventCode=self.event.getEventCode())

        URL = URL + self.event.getEventCode() + "/"

        self.mdGen.genMDBulkIssue(
            pathToSave + "/" + "_" + self.event.getEventCode(), URL,
            self.allCertificates)

        defaultFile = self.mdGen.genDefaults(pathToSave, self.issue,
                                             self.event, self.ad)
        self.genLinkCSVFile(self.allCertificates)

    def generateBadge(self, csvCertFile, config):

        pathToSave = './webPageDataGen'

        self.mdGen = mdGen()

        self.allCertificates = AllCertificates()
        self.certificateDataLoder = CertificateDataLoder()
        self.event = AnEvent()
        self.allCertificates = AllCertificates()
        self.issue = AuthorCertificate()
        self.ad = Advertisement()
        self.configurationLoader = ConfigurationLoader(self.event,
                                                       self.allCertificates,
                                                       self.issue, self.ad)

        self.configurationLoader.loadConfig(config)
        certificates = self.allCertificates.getAllCertificates()
        self.certificateDataLoder = self.certificateDataLoder.load(
            certificates, csvCertFile, False)

        URL = "https://certifyme.online/"

        self.mdGen.genMDBulkIssueBadge(
            pathToSave + "/" + "_" + self.event.getEventCode(),
            self.event.getEventCode(), URL, self.allCertificates)

        defaultFile = self.mdGen.genDefaults(pathToSave, self.issue,
                                             self.event, self.ad)
        self.genLinkCSVFile(self.allCertificates)

    def genLinkCSVFile(self, allCertificates):
        self.f = open('./webPageDataGen/namesWithLink.csv', "w")
        self.f.write("No,First Name ,Second Name , email ,Link" + "\n")
        i = 0

        for cert in allCertificates.getAllCertificates():
            i = i + 1
            firstName, secondName = cert.getName()

            line = str(
                i) + "," + firstName + "," + secondName + "," + cert.Email(
                ) + "," + cert.getWebURL() + "\n"

            self.f.write(line)

        self.f.close()
Example #5
0
class Certificates(unittest.TestCase):
    def setUp(self):
        self.allCertificates = AllCertificates()
        self.allCertificates.getAllCertificates().append(
            Certificate('Ranjith', 'Tharayil', '*****@*****.**'))
        self.allCertificates.getAllCertificates().append(
            Certificate('R', 'Tharayil', '*****@*****.**'))
        self.allCertificates.getAllCertificates().append(
            Certificate('anjith', 'Tharayil', '*****@*****.**'))

    def test_AddingCertificates(self):

        self.allCertificates.getAllCertificates().clear()
        self.allCertificates.getAllCertificates().append(
            Certificate('Ranjith', 'Tharayil', '*****@*****.**'))
        self.allCertificates.getAllCertificates().append(
            Certificate('Ranjith', 'Tharayil', '*****@*****.**'))
        self.allCertificates.getAllCertificates().append(
            Certificate('Ranjith', 'Tharayil', '*****@*****.**'))
        self.assertEqual(3, len(self.allCertificates.getAllCertificates()))

    def test_getACertificatesName(self):

        self.allCertificates.getAllCertificates().clear()
        self.allCertificates.getAllCertificates().append(
            Certificate('Ranjith', 'Tharayil', '*****@*****.**'))

        for c in self.allCertificates.getAllCertificates():
            self.assertEqual('Ranjith Tharayil', c.Name())

    def test_getACertificatesEmail(self):

        self.allCertificates.getAllCertificates().clear()
        self.allCertificates.getAllCertificates().append(
            Certificate('Ranjith', ' Tharayil', '*****@*****.**'))

        for c in self.allCertificates.getAllCertificates():
            self.assertEqual('*****@*****.**', c.Email())