Beispiel #1
0
def test_unauthenticated():
    BuyFactory.create_batch(10, public=True)
    BuyFactory.create_batch(10, public=False)
    view = BuyList.as_view()
    factory = APIRequestFactory()

    request = factory.get('/projects/api/buys')
    response = view(request)

    assert len(response.data) == 10
    for b in response.data:
        assert b['public'] is True
 def test_available_documents(self):
     procurement_method = ProcurementMethodFactory(short_name='agile_bpa')
     buy = BuyFactory(procurement_method=procurement_method)
     assert set(buy.available_docs(access_private=True)) == set([
         'qasp',
         'acquisition_plan',
         'pws',
         'rfq',
         # TODO: reactivate after template is added
         # 'interview_questions',
         'market_research',
     ])
     assert 'acquisition_plan' not in buy.available_docs(
         access_private=False)
 def test_is_under_sat(self):
     iaa = IAAFactory(budget=500000)
     project = ProjectFactory(iaa=iaa, non_cogs_amount=300000)
     buy = BuyFactory(project=project, budget=2000)
     assert buy.is_under_sat() is True
     buy.budget = 15000
     assert buy.is_under_sat() is True
     buy.budget = 150000
     assert buy.is_under_sat() is True
     buy.budget = 150001
     assert buy.is_under_sat() is False
 def test_is_micropurchase(self):
     iaa = IAAFactory(budget=500000)
     project = ProjectFactory(iaa=iaa, non_cogs_amount=300000)
     buy = BuyFactory(project=project, budget=2000)
     assert buy.is_micropurchase() is True
     buy.budget = 3500
     assert buy.is_micropurchase() is True
     buy.budget = 3501
     assert buy.is_micropurchase() is False
Beispiel #5
0
def test_edit_buy_form():
    buy = BuyFactory.create()
    data = {
        "name": buy.name,
        "description": buy.description,
        "budget": buy.budget,
        "project": buy.project.id,
        "procurement_method": buy.procurement_method,
        "qasp": "something new"
    }
    form = EditBuyForm(instance=buy)
Beispiel #6
0
def test_authenticated():
    BuyFactory.create_batch(10, public=True)
    BuyFactory.create_batch(10, public=False)
    # Create a user
    user = UserFactory.create()
    # Get required permission
    content_type = ContentType.objects.get_for_model(Project)
    permission = Permission.objects.get(
        codename='view_project',
        content_type=content_type,
    )
    user.user_permissions.add(permission)
    # Make authenticated request
    view = BuyList.as_view()
    factory = APIRequestFactory()
    request = factory.get('/projects/api/buys')
    force_authenticate(request, user=user)
    response = view(request)

    assert len(response.data) == 20
 def test_document_status(self):
     procurement_method = ProcurementMethodFactory(short_name='agile_bpa')
     buy = BuyFactory(procurement_method=procurement_method)
     assert buy.doc_completion_status(
         'market_research') == "100.00% Complete"
 def test_not_create_document(self):
     procurement_method = ProcurementMethodFactory(
         short_name='micropurchase')
     buy = BuyFactory(procurement_method=procurement_method)
     with pytest.raises(TemplateDoesNotExist):
         buy.create_document('acquisition_plan')
 def test_create_document(self):
     procurement_method = ProcurementMethodFactory(short_name='agile_bpa')
     buy = BuyFactory(procurement_method=procurement_method)
     assert not buy.qasp
     buy.create_document('qasp')
     assert buy.qasp
 def test_is_private(self):
     project = ProjectFactory(public=True)
     buy = BuyFactory(project=project, public=True)
     assert buy.is_private() is False
     buy.public = False
     assert buy.is_private() is True
 def buy(self):
     buy = BuyFactory()
     return buy
 def test_budget_remaining_clean(self):
     project = ProjectFactory.create(non_cogs_amount=200)
     buy = BuyFactory.create(budget=150,
                             project=project,
                             public=project.public)
     buy.full_clean()
 def test_budget_remaining(self):
     project = ProjectFactory.create(non_cogs_amount=200, cogs_amount=0)
     buy = BuyFactory.create(budget=50, project=project)
     assert project.budget_remaining() == 150
     buy2 = BuyFactory.create(budget=50, project=project)
     assert project.budget_remaining() == 100
 def setUp(self):
     self.buy = BuyFactory.create(public=False)
     self.user = UserFactory.create()
     self.client = Client()