Exemple #1
0
class TestLpsePemenangDoubleTender(unittest.TestCase):
    def setUp(self):
        host = 'http://lpse.tanjabtimkab.go.id'
        self.lpse = Lpse(host)

    def test_pemenang(self):
        expected_winner = {
            3346331: ['CV. NIBUNG PUTIH', '02.005.160.3-334.000'],
            3349331: ['CV. CAHAYA ERVIN GEMILANG', '02.714.891.5-331.000'],
        }

        for id_tender in expected_winner:
            detil = self.lpse.detil_paket_tender(id_tender)
            pemenang = detil.get_pemenang()

            self.assertEqual(expected_winner[id_tender][0],
                             pemenang[0]['nama_pemenang'])
            self.assertEqual(expected_winner[id_tender][1],
                             pemenang[0]['npwp'])

    def test_pemenang_hasil_evaluasi(self):
        detil = self.lpse.detil_paket_tender(3346331)
        detil.get_hasil_evaluasi()
        pemenang = list(filter(lambda x: x['p'], detil.hasil))[0]

        self.assertEqual(pemenang['nama_peserta'], 'CV. NIBUNG PUTIH')
        self.assertEqual(pemenang['npwp'], '02.005.160.3-334.000')
Exemple #2
0
def get_last_paket_id(lpse: Lpse, tender=True):
    # first
    if tender:
        data_first = lpse.get_paket_tender(start=0, length=1)
        data_last = lpse.get_paket_tender(start=0, length=1, ascending=True)
    else:
        data_first = lpse.get_paket_non_tender(start=0, length=1)
        data_last = lpse.get_paket_non_tender(start=0, length=1, ascending=True)

    if data_first and data_last:
        if not data_first['recordsTotal'] == 0:
            return [data_first['data'][0][0], data_last['data'][0][0], data_first['recordsTotal']]

    return None
Exemple #3
0
    def test_host_error(self):
        host = 'http://www.pajak.go.id'

        with self.assertRaises(LpseHostExceptions) as context:
            Lpse(host)

        self.assertIn('sepertinya bukan aplikasi SPSE'.format(host),
                      str(context.exception))
Exemple #4
0
    def test_host_without_scheme(self):
        host = 'lpse.padang.go.id'
        lpse = Lpse(host, timeout=30)

        self.assertEqual(lpse.host.startswith('http'), True)
        self.assertEqual(True, host in lpse.host)

        del lpse
Exemple #5
0
    def test_hasil_evaluasi_npwp_nama_split(self):
        with open(
                os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             'supporting_files',
                             'hasil_evaluasi_nama_npwp_test.txt')) as f:
            f.readline()
            csv_reader = csv.reader(f)
            total = 0
            success = 0

            for row in csv_reader:
                status = "ERROR"
                print("{}Test package {} from {} ...".format(
                    " " * 4, row[0], row[-1]),
                      end='')

                try:
                    lpse = Lpse(row[-1], timeout=60)
                    detil = lpse.detil_paket_non_tender(row[0])
                    detil.get_hasil_evaluasi()
                except Exception:
                    pass
                else:
                    pemenang = pyproc.utils.get_pemenang_from_hasil_evaluasi(
                        detil.hasil)
                    non_digit = re.findall('[a-zA-Z]+', pemenang[0]['npwp'])

                    self.assertEqual([], non_digit)
                    status = "OK"
                    del lpse

                total += 1
                success = success + (1 if status == "OK" else 0)
                print(status)

            print("Success Rate", success / total)
            self.assertEqual(True, success / total >= 0.8)
Exemple #6
0
class TestLpseKolomPemenangTidakLengkap(unittest.TestCase):
    def setUp(self):
        host = 'http://www.lpse-kaltara.go.id'
        self.lpse = Lpse(host)

    def test_get_pemenang(self):
        detil = self.lpse.detil_paket_tender(1569716)
        pemenang = detil.get_pemenang()
        self.assertEqual(pemenang, [{
            'nama_pemenang': 'CV. NAJAH',
            'alamat':
            'JL. IMAM BONJOL TANJUNG SELOR - Bulungan (Kab.) - Kalimantan Utara',
            'npwp': '02.673.860.9-727.000',
            'harga_penawaran': '',
            'hasil_negosiasi': ''
        }])
Exemple #7
0
 def setUp(self):
     host = 'http://lpse.tanjabtimkab.go.id'
     self.lpse = Lpse(host)
Exemple #8
0
    def setUp(self):
        host = 'http://lpse.bengkuluprov.go.id'

        lpse = Lpse(host)
        paket = lpse.get_paket_non_tender(start=0, length=1)['data']
        self.detil = lpse.detil_paket_non_tender(paket[0][0])
Exemple #9
0
 def setUp(self):
     self.lpse = Lpse('lpse.jakarta.go.id',
                      timeout=60,
                      skip_spse_check=True)
     self.id_tender_selesai = self.get_id_for_testing()
Exemple #10
0
 def setUp(self):
     self.lpse = Lpse('https://lpse.bengkuluprov.go.id', timeout=30)
Exemple #11
0
class TestPaketNonTender(unittest.TestCase):
    def setUp(self):
        self.lpse = Lpse('http://lpse.padang.go.id', timeout=30)
        self.lpse.auth_token = self.lpse.get_auth_token()

    def test_get_paket_non_tender(self):
        paket = self.lpse.get_paket_non_tender(length=5)

        self.assertEqual(len(paket['data']), 5)

    def test_get_detil_pengumuman_non_tender(self):
        detil = self.lpse.detil_paket_non_tender('2189624')
        detil.get_pengumuman()

        expected_result = {
            'kode_paket':
            '2189624',
            'nama_paket':
            'Pengadaan fishbox fiber kapasitas 50 liter, 75 liter dan 100 liter',
            'tanggal_pembuatan':
            '11 Februari 2019',
            'keterangan':
            '',
            'tahap_paket_saat_ini':
            'Paket Sudah Selesai',
            'instansi':
            'Pemerintah Daerah Kota Padang',
            'satuan_kerja':
            'DINAS KELAUTAN DAN PERIKANAN',
            'kategori':
            'Pengadaan Barang',
            'metode_pengadaan':
            'Pengadaan Langsung',
            'tahun_anggaran':
            'APBD 2019',
            'nilai_pagu_paket':
            199490000.0,
            'nilai_hps_paket':
            199481975.0,
            'lokasi_pekerjaan':
            ['7 Kec. wilayah pesisir Kota Padang - Padang (Kota)'],
            'kualifikasi_usaha':
            'Perusahaan Kecil'
        }

        self.assertEqual(detil.pengumuman, expected_result)

    def test_get_detil_peserta_non_tender(self):
        detil = self.lpse.detil_paket_non_tender('2189624')
        detil.get_peserta()

        expected_result = [{
            'no': '1',
            'nama_peserta': 'cv.samudera fiber',
            'npwp': '83.134.137.5-202.000',
            'harga_penawaran': 'Rp 199.280.125,00',
            'harga_terkoreksi': 'Rp 199.280.125,00'
        }]

        self.assertEqual(detil.peserta, expected_result)

    def test_get_detil_hasil_non_tender(self):
        detil = self.lpse.detil_paket_non_tender('2189624')
        expected_result = [{
            'no': '1',
            'nama_peserta': 'cv.samudera fiber',
            'a': 1,
            't': 1,
            'penawaran': 199280125.0,
            'penawaran_terkoreksi': 199280125.0,
            'hasil_negosiasi': 198992750.0,
            'h': 1,
            'p': True,
            'pk': True,
            'alasan': '',
            'npwp': '83.134.137.5-202.000'
        }]
        detil.get_hasil_evaluasi()

        self.assertEqual(detil.hasil, expected_result)

    def test_get_detil_pemenang_non_tender(self):
        detil = self.lpse.detil_paket_non_tender('4130624')
        expected_result = [{
            'alamat':
            'JL.SOSIOLOGI 1 A NO. 22 KOMPL. PGRI I SITEBA PADANG - Padang (Kota) - Sumatera Barat',
            'harga_penawaran': 12155000.0,
            'harga_terkoreksi': 12155000.0,
            'hasil_negosiasi': 12155000.0,
            'nama_pemenang': 'CV.DESIGN ENGINEERING CONSULTAN',
            'npwp': '02.591.921.8-201.000'
        }]
        detil.get_pemenang()

        self.assertEqual(expected_result, detil.pemenang)

    def test_get_detil_pemenang_berkontrak_non_tender(self):
        detil = self.lpse.detil_paket_non_tender('2189624')
        expected_result = [{
            'alamat':
            'Jorong Ketaping Nagari Lawang Kec. Matur - Agam (Kab.) - Sumatera Barat',
            'harga_penawaran': 199280125.0,
            'hasil_negosiasi': 198992750.0,
            'nama_pemenang': 'cv.samudera fiber',
            'npwp': '83.134.137.5-202.000'
        }]
        detil.get_pemenang_berkontrak()
        self.assertEqual(expected_result, detil.pemenang_berkontrak)

    def test_get_detil_jadwal_non_tender(self):
        detil = self.lpse.detil_paket_non_tender('2189624')
        expected_result = [{
            'no': '1',
            'tahap': 'Upload Dokumen Penawaran',
            'mulai': '18 Februari 2019 08:00',
            'sampai': '20 Februari 2019 15:59',
            'perubahan': '1 kali perubahan'
        }, {
            'no': '2',
            'tahap': 'Pembukaan Dokumen Penawaran',
            'mulai': '21 Februari 2019 08:00',
            'sampai': '21 Februari 2019 15:59',
            'perubahan': '1 kali perubahan'
        }, {
            'no': '3',
            'tahap': 'Evaluasi Penawaran',
            'mulai': '22 Februari 2019 08:00',
            'sampai': '22 Februari 2019 15:59',
            'perubahan': '2 kali perubahan'
        }, {
            'no': '4',
            'tahap': 'Klarifikasi Teknis dan Negosiasi',
            'mulai': '25 Februari 2019 08:00',
            'sampai': '25 Februari 2019 15:59',
            'perubahan': '1 kali perubahan'
        }, {
            'no': '5',
            'tahap': 'Penandatanganan Kontrak',
            'mulai': '26 Februari 2019 08:00',
            'sampai': '28 Februari 2019 15:59',
            'perubahan': '2 kali perubahan'
        }]
        detil.get_jadwal()

        self.assertEqual(detil.jadwal, expected_result)

    def test_detil_todict(self):
        detil = self.lpse.detil_paket_non_tender(2189624)
        detil.get_all_detil()

        self.assertIsInstance(detil.todict(), dict)

    def test_detil_todict_todict(self):
        detil = self.lpse.detil_paket_non_tender(2189624)
        detil.get_all_detil()
        detil.todict()
        detil.todict()

        self.assertIsInstance(detil.todict(), dict)

    def test_detil_id_random(self):
        detil = self.lpse.detil_paket_tender(111)

        self.assertRaises(LpseServerExceptions, detil.get_all_detil)
Exemple #12
0
 def setUp(self):
     self.lpse = Lpse('http://lpse.jakarta.go.id', timeout=30)
     self.lpse.skip_spse_check = True
     self.lpse.auth_token = self.lpse.get_auth_token()
     self.id_non_tender_for_testing = self.get_id_for_testing()
Exemple #13
0
class TestPaketNonTender(unittest.TestCase):
    def setUp(self):
        self.lpse = Lpse('http://lpse.jakarta.go.id', timeout=30)
        self.lpse.skip_spse_check = True
        self.lpse.auth_token = self.lpse.get_auth_token()
        self.id_non_tender_for_testing = self.get_id_for_testing()

    def get_id_for_testing(self):
        paket = self.lpse.get_paket_non_tender(start=0, length=50)

        for i in paket['data']:
            if i[3].lower().strip() == 'paket sudah selesai':
                return i[0]

    def test_get_paket_non_tender(self):
        paket = self.lpse.get_paket_non_tender(length=5)

        self.assertEqual(len(paket['data']), 5)

    def test_get_detil_pengumuman_non_tender(self):
        detil = self.lpse.detil_paket_non_tender(
            self.id_non_tender_for_testing)
        detil.get_pengumuman()

        for i, v in detil.pengumuman.items():
            self.assertIsNotNone(v)

    def test_get_detil_peserta_non_tender(self):
        detil = self.lpse.detil_paket_non_tender(
            self.id_non_tender_for_testing)
        detil.get_peserta()

        for peserta in detil.peserta:
            for i, v in peserta.items():
                self.assertIsNotNone(v)

    def test_get_detil_hasil_non_tender(self):
        detil = self.lpse.detil_paket_non_tender(
            self.id_non_tender_for_testing)
        detil.get_hasil_evaluasi()

        for hasil in detil.hasil:
            for i, v in hasil.items():
                self.assertIsNotNone(v)

    def test_get_detil_pemenang_non_tender(self):
        detil = self.lpse.detil_paket_non_tender(
            self.id_non_tender_for_testing)
        detil.get_pemenang()

        for pemenang in detil.pemenang:
            for i, v in pemenang.items():
                self.assertIsNotNone(v)

    def test_get_detil_jadwal_non_tender(self):
        detil = self.lpse.detil_paket_non_tender(
            self.id_non_tender_for_testing)
        detil.get_jadwal()

        for row in detil.jadwal:
            for i, v in row.items():
                self.assertIsNotNone(v)

    def test_detil_todict(self):
        detil = self.lpse.detil_paket_non_tender(
            self.id_non_tender_for_testing)
        detil.get_all_detil()

        self.assertIsInstance(detil.todict(), dict)

    def test_detil_todict_todict(self):
        detil = self.lpse.detil_paket_non_tender(
            self.id_non_tender_for_testing)
        detil.get_all_detil()
        detil.todict()
        detil.todict()

        self.assertIsInstance(detil.todict(), dict)

    def test_detil_id_random(self):
        detil = self.lpse.detil_paket_tender(111)

        self.assertRaises(LpseServerExceptions, detil.get_all_detil)

    def tearDown(self):
        del self.lpse
Exemple #14
0
 def setUp(self):
     host = 'http://www.lpse-kaltara.go.id'
     self.lpse = Lpse(host)
Exemple #15
0
 def setUp(self):
     self.lpse = Lpse('http://lpse.padang.go.id', timeout=30)
     self.lpse.auth_token = self.lpse.get_auth_token()
Exemple #16
0
class TestLpse(unittest.TestCase):
    def setUp(self):
        self.lpse = Lpse('https://lpse.bengkuluprov.go.id', timeout=30)

    def test_version(self):
        v = self.lpse.version
        v_2 = ''.join(re.findall(r'(SPSE v\d+\.\d+u\d+)', v))

        self.assertEqual(v, v_2)

    def test_get_auth_token(self):
        token = self.lpse.get_auth_token()
        token_from_session = self.lpse.session.cookies['SPSE_SESSION'].split(
            '___')[1].split('=')[1].strip('&')
        self.assertEqual(token, token_from_session)

    def test_get_paket_tender_kosong(self):
        data = self.lpse.get_paket_tender()

        self.assertIsInstance(data, dict)

    def test_get_paket_tender_isi(self):
        data = self.lpse.get_paket_tender(length=2)

        self.assertEqual(2, len(data['data']))

    def test_get_paket_tender_pagination(self):
        data_1 = self.lpse.get_paket_tender(length=5)
        data_2 = self.lpse.get_paket_tender(start=4, length=5)

        self.assertEqual(data_1['data'][-1], data_2['data'][0])

    def test_get_paket_tender_search(self):
        keyword = 'konsentrat'
        data = self.lpse.get_paket_tender(length=1, search_keyword=keyword)

        for i in data['data']:
            self.assertEqual(True, keyword.lower() in i[1].lower())

    def test_get_detil_tender(self):
        data = self.lpse.get_paket_tender(length=1)
        id_paket = data['data'][0][0]
        detil = self.lpse.detil_paket_tender(id_paket)

        detil.get_pengumuman()

        self.assertEqual(id_paket, detil.pengumuman['kode_tender'])

    def test_get_peserta_tender(self):
        data = self.lpse.get_paket_tender(length=1)
        id_paket = data['data'][0][0]
        detil = self.lpse.detil_paket_tender(id_paket)

        detil.get_peserta()

        self.assertIsInstance(detil.peserta, list)

    def test_get_hasil_evaluasi_tender(self):
        detil = self.lpse.detil_paket_tender(3676267)

        detil.get_hasil_evaluasi()

        self.assertIsInstance(detil.hasil, list)

    def test_get_pemenang_tender(self):
        detil = self.lpse.detil_paket_tender(3676267)
        detil.get_pemenang()

        nama_pemenang = 'CV. PELANGI NUSANTARA'
        npwp_pemenang = '02.352.426.7-311.000'

        self.assertEqual(nama_pemenang, detil.pemenang[0]['nama_pemenang'])
        self.assertEqual(npwp_pemenang, detil.pemenang[0]['npwp'])

    def test_get_pemenang_tender_kosong(self):
        data = self.lpse.get_paket_tender(length=1)
        id_paket = data['data'][0][0]
        detil = self.lpse.detil_paket_tender(id_paket)
        pemenang = detil.get_pemenang()

        self.assertEqual(pemenang, None)

    def test_get_pemenang_berkontrak_tender(self):
        detil = self.lpse.detil_paket_tender(3676267)
        detil.get_pemenang_berkontrak()

        expected_result = {
            'nama_pemenang': 'CV. PELANGI NUSANTARA',
            'alamat':
            'Jl. Meranti 03 No. 11 Sawah Lebar Bengkulu - Bengkulu (Kota) - Bengkulu',
            'npwp': '02.352.426.7-311.000',
            'harga_penawaran': 791309449.11,
            'hasil_negosiasi': 791309449.11
        }

        self.assertEqual(expected_result, detil.pemenang_berkontrak[0])

    def test_get_jadwal_tender(self):
        data = self.lpse.get_paket_tender(length=1)
        detil = self.lpse.detil_paket_tender(data['data'][0][0])
        detil.get_jadwal()
        jadwal_key = ['no', 'tahap', 'mulai', 'sampai', 'perubahan']

        self.assertIsInstance(detil.jadwal, list)
        for key in detil.jadwal[0]:
            self.assertEqual(True, key in jadwal_key)

    def test_detil_todict(self):
        detil = self.lpse.detil_paket_tender(3676267)
        detil.get_all_detil()

        self.assertIsInstance(detil.todict(), dict)

    def test_detil_todict_todict(self):
        detil = self.lpse.detil_paket_tender(3676267)
        detil.get_all_detil()
        detil.todict()
        detil.todict()

        self.assertIsInstance(detil.todict(), dict)

    def test_detil_id_random(self):
        detil = self.lpse.detil_paket_tender(111)

        self.assertRaises(LpseServerExceptions, detil.get_all_detil)
Exemple #17
0
    def test_host_without_scheme(self):
        host = 'https://lpse.bengkuluprov.go.id'
        lpse = Lpse(host)

        self.assertEqual(lpse.host.startswith('http'), True)
        self.assertEqual(True, host in lpse.host)
Exemple #18
0
def main():
    print_info()
    cache_folder = create_cache_folder()
    disable_warnings(InsecureRequestWarning)

    parser = argparse.ArgumentParser()
    parser.add_argument("--host",
                        help="Alamat Website LPSE",
                        default=None,
                        type=str)
    parser.add_argument("--out",
                        help="Nama file hasil download LPSE",
                        default=None,
                        type=str)
    parser.add_argument("-r",
                        "--read",
                        help="Membaca host dari file",
                        default=None,
                        type=str)
    parser.add_argument("--tahun-anggaran",
                        help="Tahun Anggaran untuk di download",
                        default=str(datetime.now().year),
                        type=str)
    parser.add_argument("--workers",
                        help="Jumlah worker untuk download detil paket",
                        default=8,
                        type=int)
    parser.add_argument("--fetch-size",
                        help="Jumlah row yang didownload per halaman",
                        default=100,
                        type=int)
    parser.add_argument("--timeout", help="Set timeout", default=30, type=int)
    parser.add_argument("--keep",
                        help="Tidak menghapus folder cache",
                        action="store_true")
    parser.add_argument(
        "--index-download-delay",
        help="Menambahkan delay untuk setiap iterasi halaman index",
        default=1,
        type=int)
    parser.add_argument(
        "--non-tender",
        help="Download paket non tender (penunjukkan langsung)",
        action="store_true")
    parser.add_argument("--force",
                        "-f",
                        help="Clear index sebelum mendownload data",
                        action="store_true")
    parser.add_argument("--skip-spse-check",
                        help="skip cek versi SPSE",
                        action="store_true")

    args = parser.parse_args()

    error, tahun_anggaran = parse_tahun_anggaran(args.tahun_anggaran)
    jenis_paket = 'non_tender' if args.non_tender else 'tender'

    if error:
        print("ERROR: format tahun anggaran tidak dikenal ",
              args.tahun_anggaran)
        exit(1)

    if args.host:
        host_list = args.host.strip().split(',')
    elif args.read:
        with open(args.read, 'r', encoding='utf8',
                  errors="ignore") as host_file:
            host_list = host_file.read().strip().split()
    else:
        parser.print_help()
        print("\nERROR: Argumen --host atau --read tidak ditemukan!")
        exit(1)

    # download index
    detil_downloader = DetilDownloader(workers=args.workers,
                                       timeout=args.timeout,
                                       use_cache=not args.force)
    detil_downloader.spawn_worker()

    try:
        for host in host_list:
            _ = host.split(';')
            host = _[0].strip()
            custom_file_name = None

            if args.host and args.out:
                custom_file_name = args.out.strip()
            elif len(_) > 1:
                custom_file_name = _[1].strip()

            try:
                print("=" * len(host))
                print(host)
                print("=" * len(host))
                print("tahun anggaran :", ' - '.join(map(str, tahun_anggaran)))
                print("jenis paket    :",
                      'Pengadaan Langsung' if args.non_tender else 'Tender')
                _lpse = Lpse(host=host,
                             timeout=args.timeout,
                             skip_spse_check=args.skip_spse_check)
                last_paket_id = get_last_paket_id(_lpse, not args.non_tender)

                if last_paket_id is None:
                    print("- Data kosong")
                    continue

                index_path_exists, index_path = get_index_path(
                    cache_folder, _lpse.host, jenis_paket, last_paket_id)

                if args.force:
                    rmtree(os.path.dirname(index_path))
                    os.mkdir(os.path.dirname(index_path))
                    index_path_exists = False

                if not index_path_exists:
                    index_path = lock_index(index_path)

                for downloadinfo in download_index(_lpse, args.fetch_size,
                                                   args.timeout,
                                                   args.non_tender, index_path,
                                                   index_path_exists,
                                                   args.force,
                                                   args.index_download_delay):
                    if index_path_exists and not args.force:
                        print(downloadinfo, end='\r')
                        continue

                    print("- halaman {} of {} ({} row)".format(*downloadinfo),
                          end='\r')

                print("\n- download selesai\n")

                index_path = unlock_index(index_path)

            except Exception as e:
                print("ERROR:", str(e))
                error_writer('{}|{}'.format(host, str(e)))
                continue

            print("Downloading")

            detil_downloader.reset()
            detil_downloader.set_host(lpse=_lpse)

            get_detil(downloader=detil_downloader,
                      jenis_paket=jenis_paket,
                      tahun_anggaran=tahun_anggaran,
                      index_path=index_path)
            print("\n- download selesai\n")

            print("Menggabungkan Data")
            try:
                combine_data(_lpse.host,
                             jenis_paket,
                             not args.keep,
                             filename=custom_file_name,
                             tahun_anggaran=tahun_anggaran)
            except Exception as e:
                print("ERROR:", str(e))
                error_writer('{}|menggabungkan {}'.format(host, str(e)))
            print("- proses selesai")

    except KeyboardInterrupt:
        error = "\n\nProses dibatalkan oleh user, bye!"
        print(error)
        error_writer("{}|{}".format(detil_downloader.lpse.host, error))
        detil_downloader.stop_process()
    except Exception as e:
        print("\n\nERROR:", e)
        error_writer("{}|{}".format(detil_downloader.lpse.host, str(e)))
        detil_downloader.stop_process()
    finally:
        for i in range(detil_downloader.workers):
            detil_downloader.queue.put(None)

        for t in detil_downloader.threads_pool:
            t.join()
Exemple #19
0
class TestLpse(unittest.TestCase):
    def setUp(self):
        self.lpse = Lpse('lpse.jakarta.go.id',
                         timeout=60,
                         skip_spse_check=True)
        self.id_tender_selesai = self.get_id_for_testing()

    def get_id_for_testing(self):
        paket = self.lpse.get_paket_tender(start=0, length=50)

        for i in paket['data']:
            if i[3].lower().strip() == 'tender sudah selesai':
                return i[0]

    def test_get_auth_token(self):
        token = self.lpse.get_auth_token()
        token_from_session = self.lpse.session.cookies['SPSE_SESSION'].split(
            '___')[1].split('=')[1].strip('&')
        self.assertEqual(token, token_from_session)

    def test_get_paket_tender_kosong(self):
        data = self.lpse.get_paket_tender()

        self.assertIsInstance(data, dict)

    def test_get_paket_tender_isi(self):
        data = self.lpse.get_paket_tender(length=2)

        self.assertEqual(2, len(data['data']))

    def test_get_paket_tender_pagination(self):
        data_1 = self.lpse.get_paket_tender(length=5)
        data_2 = self.lpse.get_paket_tender(start=4, length=5)

        self.assertEqual(data_1['data'][-1], data_2['data'][0])

    def test_get_paket_tender_search(self):
        keyword = 'sekolah'
        data = self.lpse.get_paket_tender(length=1, search_keyword=keyword)

        for i in data['data']:
            self.assertEqual(True, keyword.lower() in i[1].lower())

    def test_get_detil_tender(self):
        data = self.lpse.get_paket_tender(length=1)
        id_paket = data['data'][0][0]
        detil = self.lpse.detil_paket_tender(id_paket)

        detil.get_pengumuman()

        self.assertEqual(id_paket, detil.pengumuman['kode_tender'])

    def test_get_peserta_tender(self):
        data = self.lpse.get_paket_tender(length=1)
        id_paket = data['data'][0][0]
        detil = self.lpse.detil_paket_tender(id_paket)

        detil.get_peserta()

        self.assertIsInstance(detil.peserta, list)

    def test_get_hasil_evaluasi_tender(self):
        detil = self.lpse.detil_paket_tender(self.id_tender_selesai)

        detil.get_hasil_evaluasi()

        self.assertIsInstance(detil.hasil, list)

    def test_get_pemenang_tender(self):
        detil = self.lpse.detil_paket_tender(self.id_tender_selesai)
        detil.get_pemenang()
        for i, v in detil.pemenang[0].items():
            self.assertIsNotNone(v)

    def test_get_pemenang_tender_kosong(self):
        # data = self.lpse.get_paket_tender(length=1)
        # id_paket = data['data'][0][0]
        # detil = self.lpse.detil_paket_tender(id_paket)
        # pemenang = detil.get_pemenang()
        # print(pemenang)
        #
        # self.assertEqual(pemenang, None)
        print(
            "Data terlalu dinamis untuk di test. Uncomment fungsi ini lalu masukan ID tender secara manual untuk di test"
        )
        pass

    def test_get_pemenang_berkontrak_tender(self):
        detil = self.lpse.detil_paket_tender(self.id_tender_selesai)
        detil.get_pemenang_berkontrak()

        if not detil.pemenang_berkontrak:
            print("Belum ada pemenang berkontrak")
            return

        for i, v in detil.pemenang_berkontrak[0].items():
            self.assertIsNotNone(v)

    def test_get_jadwal_tender(self):
        data = self.lpse.get_paket_tender(length=1)
        detil = self.lpse.detil_paket_tender(data['data'][0][0])
        detil.get_jadwal()
        jadwal_key = ['no', 'tahap', 'mulai', 'sampai', 'perubahan']

        self.assertIsInstance(detil.jadwal, list)
        for key in detil.jadwal[0]:
            self.assertEqual(True, key in jadwal_key)

    def test_detil_todict(self):
        detil = self.lpse.detil_paket_tender(self.id_tender_selesai)
        detil.get_all_detil()

        self.assertIsInstance(detil.todict(), dict)

    def test_detil_todict_todict(self):
        detil = self.lpse.detil_paket_tender(self.id_tender_selesai)
        detil.get_all_detil()
        detil.todict()
        detil.todict()

        self.assertIsInstance(detil.todict(), dict)

    def test_detil_id_random(self):
        detil = self.lpse.detil_paket_tender(111)

        self.assertRaises(LpseServerExceptions, detil.get_all_detil)

    def tearDown(self):
        del self.lpse