def test_01(self):
        cs = CertificateSearch()
        cs.set_period(2013, 1)
        cs.filter_technology("Wind")
        cs.filter_scheme('REGO')

        self.assertTrue(cs.get_data())
        self.assertIsInstance(cs[0], Certificates)
        self.assertEqual(cs[0].period, 'Jan-2013')
Beispiel #2
0
        print("Contacting Ofgem and preparing to search.\n")
        ocs = CertificateSearch()

        crit = "Searching Ofgem Certificates: "
        crits = []

        if args.scheme:
            ocs.filter_scheme(args.scheme)
            crits.append('\n\tscheme %s' % args.scheme)

        if args.generator:
            ocs.filter_generator_id(args.generator.upper())
            crits.append("\n\tgenerator id is '%s'" % args.generator.upper())

        if args.month and  args.year:
            ocs.set_period(args.year, args.month)
            crits.append('\n\tperiod should be {} {}'.format(args.month, args.year))
        else:
            if args.month:
                ocs.set_month(args.month)
                crits.append('\n\tmonth %s' % args.month)
            if args.year:
                ocs.set_year(args.year)
                crits.append('\n\tyear %s' % args.year)

        print("Searching Ofgem for certificates matching:{}\n".format(", ".join(crits)))
        ocs.get_data()
    else:
        ocs = CertificateSearch(filename=args.filename)

    print("Total of %d records returned" % len(ocs))