Beispiel #1
0
    def test_update_old_solicitations(self):
        conn_string = get_db_url()
        dal = DataAccessLayer(conn_string)
        dal.connect()

        with session_scope(dal) as session:
            sam_utils.update_old_solicitations(session,
                                               age_cutoff=365,
                                               max_tests=5)
Beispiel #2
0
    def setUp(self):
        self.data = [mock_data_for_db.copy()]
        self.dal = DataAccessLayer(conn_string=get_db_url())
        self.dal.create_test_postgres_db()
        self.dal.connect()

        with session_scope(self.dal) as session:
            insert_notice_types(session)

        self.maxDiff = None
Beispiel #3
0
import logging

from utils import get_opps
from utils.predict import Predict
from utils.db.db_utils import get_db_url, session_scope, DataAccessLayer, insert_data_into_solicitations_table, insert_notice_types
from utils.json_log_formatter import CustomJsonFormatter, configureLogger
from utils.sam_utils import update_old_solicitations, opportunity_filter_function, set_psc_code_download_list
import sys
import datetime
import os

logger = logging.getLogger()
configureLogger(logger, stdout_level=logging.INFO)

conn_string = get_db_url()
dal = DataAccessLayer(conn_string)
dal.connect()


def main(limit=None, updateOld=True, opportunity_filter_function=None, target_sol_types="o,k", skip_attachments=False, from_date = 'yesterday', to_date='yesterday'):
    try:
        if limit:
            logger.error("Artifical limit of {} placed on the number of opportunities processed.  Should not happen in production.".format(limit))

        if not updateOld:
            logger.error("Set to NOT update old solicitations. Should not happen in production.".format(limit))

        with session_scope(dal) as session:
            # make sure that the notice types are configured and committed before going further
            insert_notice_types(session)
Beispiel #4
0
 def setUp(self):
     conn_string = get_db_url()
     self.dal = DataAccessLayer(conn_string)
     self.dal.create_test_postgres_db()
     self.dal.connect()
     self.main = main
Beispiel #5
0
 def setUp(self):
     conn_string = get_db_url()
     self.predicted_nightly_data = {
         'AMDCSS': [{
             'date':
             '0506',
             'year':
             '18',
             'agency':
             'department of justice',
             'office':
             'federal bureau of investigation',
             'location':
             'procurement section',
             'zip':
             '20535',
             'classcod':
             '70',
             'naics':
             '511210',
             'offadd':
             '935 pennsylvania avenue, n.w. washington dc 20535',
             'subject':
             'enterprise business process management software tool',
             'solnbr':
             'rfp-e-bpm-djf-18-0800-pr-0000828',
             'ntype':
             'combine',
             'contact':
             'clark kent, contracting officer, phone 5555555555, email [email protected]',
             'desc':
             '  link to document',
             'url':
             'url',
             'setaside':
             'n/a',
             'popcountry':
             'us',
             'popzip':
             '20535',
             'popaddress':
             '935 pennsylvania ave. n.w. washington, dc  ',
             'attachments': [{
                 'filename': 'test.txt',
                 'machine_readable': True,
                 'text': 'test_text_0',
                 'url': 'test_url_0',
                 'prediction': 1,
                 'decision_boundary': 0,
                 'validation': None,
                 'trained': False
             }, {
                 'filename': 'test.txt',
                 'machine_readable': True,
                 'text': 'test_text_1',
                 'url': 'test_url_1',
                 'prediction': 1,
                 'decision_boundary': 0,
                 'validation': None,
                 'trained': False
             }, {
                 'filename': 'test.txt',
                 'machine_readable': True,
                 'text': 'test_text_2',
                 'url': 'test_url_2',
                 'prediction': 1,
                 'decision_boundary': 0,
                 'validation': None,
                 'trained': False
             }, {
                 'filename': 'test.txt',
                 'machine_readable': True,
                 'text': 'test_text_3',
                 'url': 'test_url_3',
                 'prediction': 1,
                 'decision_boundary': 0,
                 'validation': None,
                 'trained': False
             }, {
                 'filename': 'test.txt',
                 'machine_readable': True,
                 'text': 'test_text_4',
                 'url': 'test_url_4',
                 'prediction': 1,
                 'decision_boundary': 0,
                 'validation': None,
                 'trained': False
             }, {
                 'filename': 'test.txt',
                 'machine_readable': True,
                 'text': 'test_text_5',
                 'url': 'test_url_5',
                 'prediction': 1,
                 'decision_boundary': 0,
                 'validation': None,
                 'trained': False
             }, {
                 'filename': 'test.txt',
                 'machine_readable': True,
                 'text': 'test_text_6',
                 'url': 'test_url_6',
                 'prediction': 1,
                 'decision_boundary': 0,
                 'validation': None,
                 'trained': False
             }],
             'compliant':
             0
         }],
         'MOD': [],
         'COMBINE': [{
             'date': '0506',
             'year': '18',
             'agency': 'defense logistics agency',
             'office': 'dla acquisition locations',
             'location': 'dla aviation - bsm',
             'zip': '23297',
             'classcod': '66',
             'naics': '334511',
             'offadd': '334511',
             'subject': 'subject',
             'solnbr': 'spe4a618t934n',
             'respdate': '051418',
             'archdate': '06132018',
             'contact': '*****@*****.**',
             'desc': 'test123',
             'url': 'test_url',
             'setaside': 'n/a  ',
             'attachments': [],
             'compliant': 0
         }],
         'PRESOL': []
     }
     self.predicted_nightly_data_day_two = {
         'AMDCSS': [{
             'date':
             '0506',
             'year':
             '17',
             'agency':
             'defense logistics agency',
             'office':
             'dla acquisition locations',
             'location':
             'dla aviation - bsm',
             'zip':
             '23297',
             'classcod':
             '66',
             'naics':
             '334511',
             'offadd':
             '334511',
             'subject':
             'subject',
             'solnbr':
             'spe4a618t934n',
             'respdate':
             '051418',
             'archdate':
             '06132018',
             'contact':
             '*****@*****.**',
             'desc':
             'test123',
             'url':
             'test_url',
             'setaside':
             'n/a  ',
             'attachments': [{
                 'filename': 'test.txt',
                 'machine_readable': True,
                 'text': 'test_text_0',
                 'url': 'test_url_0',
                 'prediction': 1,
                 'decision_boundary': 0,
                 'validation': None,
                 'trained': False
             }],
             'compliant':
             0
         }]
     }
     self.dal = DataAccessLayer(conn_string=conn_string)
     self.dal.create_test_postgres_db()
     self.dal.connect()
     self.maxDiff = None
Beispiel #6
0
    def setUp(self):
        self.dal = DataAccessLayer(conn_string=get_db_url())
        self.dal.connect()

        with session_scope(self.dal) as session:
            insert_notice_types(session)