Ejemplo n.º 1
0
    def setUp(self):
        super(TestScout, self).setUp()
        # insert departments
        self.department1 = DepartmentFactory()

        # insert the users/roles
        self.admin_role = insert_a_role('admin')
        self.superadmin_role = insert_a_role('superadmin')
        self.admin_user = insert_a_user(email='*****@*****.**',
                                        role=self.admin_role,
                                        department=self.department1)
        self.superadmin_user = insert_a_user(email='*****@*****.**',
                                             role=self.superadmin_role,
                                             department=self.department1)

        # insert the companies/contracts
        self.company1 = insert_a_company(name='ship', insert_contract=False)
        self.company2 = insert_a_company(name='boat', insert_contract=False)
        insert_a_contract(description='vessel',
                          companies=[self.company2],
                          line_items=[LineItem(description='NAVY')])
        self.contract1 = insert_a_contract(
            description='sail',
            financial_id=123,
            companies=[self.company1],
            line_items=[LineItem(description='sunfish')])
        self.contract2 = insert_a_contract(description='sunfish',
                                           financial_id=456)
    def setUp(self):
        super(TestScout, self).setUp()
        # insert departments
        self.department1 = DepartmentFactory()

        # insert the users/roles
        self.admin_role = insert_a_role('admin')
        self.superadmin_role = insert_a_role('superadmin')
        self.admin_user = insert_a_user(
            email='*****@*****.**', role=self.admin_role, department=self.department1
        )
        self.superadmin_user = insert_a_user(
            email='*****@*****.**', role=self.superadmin_role, department=self.department1
        )

        # insert the companies/contracts
        self.company1 = insert_a_company(name='ship', insert_contract=False)
        self.company2 = insert_a_company(name='boat', insert_contract=False)
        insert_a_contract(
            description='vessel', companies=[self.company2], line_items=[LineItem(description='NAVY')]
        )
        self.contract1 = insert_a_contract(
            description='sail', financial_id=123, companies=[self.company1],
            line_items=[LineItem(description='sunfish')]
        )
        self.contract2 = insert_a_contract(
            description='sunfish', financial_id=456
        )
Ejemplo n.º 3
0
    def setUp(self):
        super(TestConductorMetrics, self).setUp()

        self.assign_contract()
        transition_url_1 = self.build_detail_view(
            self.contract1) + '/transition'

        self.assign_contract(contract=self.contract2)
        transition_url_2 = self.build_detail_view(
            self.contract2) + '/transition'

        for stage in self.flow.stage_order:
            self.client.get(transition_url_1)
            self.client.get(transition_url_2)

        self.contract3 = insert_a_contract(
            contract_type=self.county_type,
            description='scuba repair 2',
            financial_id=789,
            expiration_date=datetime.date.today() + datetime.timedelta(120),
            properties=[{
                'key': 'Spec Number',
                'value': '789'
            }],
            is_visible=True)
    def setUp(self):
        super(TestConductorSetup, self).setUp()
        # create a conductor and general staff person
        self.county_type = ContractTypeFactory.create(**{
            'name': 'County', 'allow_opportunities': True, 'managed_by_conductor': True
        })
        self.department = DepartmentFactory.create(**{'name': 'test department'})

        self.conductor_role_id = insert_a_role('conductor')
        self.staff_role_id = insert_a_role('staff')
        self.conductor = insert_a_user(email='*****@*****.**', role=self.conductor_role_id)
        self.staff = insert_a_user(email='*****@*****.**', role=self.staff_role_id)
        self.conductor2 = insert_a_user(email='*****@*****.**', role=self.conductor_role_id)

        # create three stages, and set up a flow between them
        self.stage1 = insert_a_stage(
            name='stage1', send_notifs=True, post_opportunities=True,
            default_message='i am a default message'
        )
        self.stage2 = insert_a_stage(name='stage2', send_notifs=True, post_opportunities=False)
        self.stage3 = insert_a_stage(name='stage3', send_notifs=False, post_opportunities=False)

        self.flow = insert_a_flow(stage_ids=[self.stage1.id, self.stage2.id, self.stage3.id])
        self.flow2 = insert_a_flow(name='test2', stage_ids=[self.stage1.id, self.stage3.id, self.stage2.id])
        self.simple_flow = insert_a_flow(name='simple', stage_ids=[self.stage1.id])

        # create two contracts
        self.contract1 = insert_a_contract(
            contract_type=self.county_type, description='scuba supplies', financial_id=123,
            expiration_date=datetime.date.today(), properties=[{'key': 'Spec Number', 'value': '123'}],
            is_visible=True, department=self.department, has_metrics=True
        )
        self.contract2 = insert_a_contract(
            contract_type=self.county_type, description='scuba repair', financial_id=456,
            expiration_date=datetime.date.today() + datetime.timedelta(120),
            properties=[{'key': 'Spec Number', 'value': '456'}],
            is_visible=True, has_metrics=True
        )

        self.category = CategoryFactory.create()

        self.login_user(self.conductor)
        self.detail_view = '/conductor/contract/{}/stage/{}'
        self.transition_view = '/conductor/contract/{}/stage/{}/'
    def test_metrics_tsv_download_all(self):
        insert_a_contract(
            contract_type=self.county_type,
            description="scuba supplies 2",
            financial_id=789,
            expiration_date=datetime.date.today(),
            properties=[{"key": "Spec Number", "value": "789"}],
            is_visible=False,
            department=self.department,
            is_archived=False,
        )
        insert_a_contract(
            contract_type=self.county_type,
            description="scuba supplies 3",
            financial_id=101,
            expiration_date=datetime.date.today(),
            properties=[{"key": "Spec Number", "value": "789"}],
            is_visible=True,
            department=self.department,
            is_archived=True,
        )
        insert_a_contract(
            contract_type=self.county_type,
            description="scuba supplies 4",
            financial_id=102,
            expiration_date=datetime.date.today(),
            properties=[{"key": "Spec Number", "value": "789"}],
            is_visible=True,
            department=self.department,
            is_archived=False,
            parent_id=self.contract1.id,
        )
        self.contract1.update(is_archived=True)
        self.contract3.update(has_metrics=False)
        db.session.commit()
        request = self.client.get("/conductor/metrics/download/all", follow_redirects=True)
        self.assertEquals(request.mimetype, "text/tsv")
        self.assertEquals(
            request.headers.get("Content-Disposition"),
            "attachment; filename=conductor-all-{}.tsv".format(datetime.date.today()),
        )

        tsv_data = request.data.split("\n")[:-1]
        # eight contracts + a header row
        self.assertEquals(len(tsv_data), 9)
        status, in_metrics = defaultdict(int), defaultdict(int)
        for i in tsv_data[1:]:
            status[i.split("\t")[-1]] += 1
            in_metrics[i.split("\t")[-2]] += 1

        self.assertEquals(status["archived"], 1)
        self.assertEquals(status["completed"], 1)
        self.assertEquals(status["started"], 2)
        self.assertEquals(status["not started, in all contracts list"], 2)
        self.assertEquals(status["child contract complete"], 1)
        self.assertEquals(status["removed from conductor"], 1)

        self.assertEquals(in_metrics["True"], 7)
        self.assertEquals(in_metrics["False"], 1)
Ejemplo n.º 6
0
    def test_metrics_tsv_download_all(self):
        insert_a_contract(
            contract_type=self.county_type, description='scuba supplies 2', financial_id=789,
            expiration_date=datetime.date.today(), properties=[{'key': 'Spec Number', 'value': '789'}],
            is_visible=True, department=self.department, is_archived=False
        )
        db.session.commit()
        request = self.client.get('/conductor/metrics/download/all', follow_redirects=True)
        self.assertEquals(request.mimetype, 'text/tsv')
        self.assertEquals(
            request.headers.get('Content-Disposition'),
            "attachment; filename=conductor-all-{}.tsv".format(datetime.date.today())
        )

        tsv_data = request.data.split('\n')[:-1]
        self.assertEquals(len(tsv_data), 4)
        status = defaultdict(int)
        for i in tsv_data[1:]:
            status[i.split('\t')[-1]] += 1

        self.assertEquals(status['not started'], 1)
        self.assertEquals(status['started'], 2)
    def setUp(self):
        super(TestConductorMetrics, self).setUp()

        self.assign_contract()
        transition_url_1 = self.build_detail_view(self.contract1) + "/transition"

        self.assign_contract(contract=self.contract2)
        transition_url_2 = self.build_detail_view(self.contract2) + "/transition"

        for stage in self.flow.stage_order:
            self.client.get(transition_url_1)
            self.client.get(transition_url_2)

        self.contract3 = insert_a_contract(
            contract_type=self.county_type,
            description="scuba repair 2",
            financial_id=789,
            expiration_date=datetime.date.today() + datetime.timedelta(120),
            properties=[{"key": "Spec Number", "value": "789"}],
            is_visible=True,
        )
Ejemplo n.º 8
0
    def test_metrics_tsv_download_all(self):
        insert_a_contract(contract_type=self.county_type,
                          description='scuba supplies 2',
                          financial_id=789,
                          expiration_date=datetime.date.today(),
                          properties=[{
                              'key': 'Spec Number',
                              'value': '789'
                          }],
                          is_visible=False,
                          department=self.department,
                          is_archived=False)
        insert_a_contract(contract_type=self.county_type,
                          description='scuba supplies 3',
                          financial_id=101,
                          expiration_date=datetime.date.today(),
                          properties=[{
                              'key': 'Spec Number',
                              'value': '789'
                          }],
                          is_visible=True,
                          department=self.department,
                          is_archived=True)
        insert_a_contract(contract_type=self.county_type,
                          description='scuba supplies 4',
                          financial_id=102,
                          expiration_date=datetime.date.today(),
                          properties=[{
                              'key': 'Spec Number',
                              'value': '789'
                          }],
                          is_visible=True,
                          department=self.department,
                          is_archived=False,
                          parent_id=self.contract1.id)
        self.contract1.update(is_archived=True)
        self.contract3.update(has_metrics=False)
        db.session.commit()
        request = self.client.get('/conductor/metrics/download/all',
                                  follow_redirects=True)
        self.assertEquals(request.mimetype, 'text/tsv')
        self.assertEquals(
            request.headers.get('Content-Disposition'),
            "attachment; filename=conductor-all-{}.tsv".format(
                datetime.date.today()))

        tsv_data = request.data.split('\n')[:-1]
        # eight contracts + a header row
        self.assertEquals(len(tsv_data), 9)
        status, in_metrics = defaultdict(int), defaultdict(int)
        for i in tsv_data[1:]:
            status[i.split('\t')[-1]] += 1
            in_metrics[i.split('\t')[-2]] += 1

        self.assertEquals(status['archived'], 1)
        self.assertEquals(status['completed'], 1)
        self.assertEquals(status['started'], 2)
        self.assertEquals(status['not started, in all contracts list'], 2)
        self.assertEquals(status['child contract complete'], 1)
        self.assertEquals(status['removed from conductor'], 1)

        self.assertEquals(in_metrics['True'], 7)
        self.assertEquals(in_metrics['False'], 1)