def data_one_project(self): database_population.create_project() self.assertEqual(ProjectsAllInformationExcel._headers(), [ 'Key', 'Grant scheme', 'Name of PI', 'Organisation', 'Gender', 'Career stage', 'Geographic focus', 'Location', 'Keywords', 'Title', 'Signed date', 'Start date', 'End date', 'Allocated budget', 'Balance due', 'Status' ]) self.assertEqual(ProjectsAllInformationExcel._rows(), [{ 'Key': 'SPI-2020-001', 'Signed date': 'No grant agreement attached', 'Organisation': '', 'Title': 'This is a test project', 'Start date': datetime.date(2020, 1, 10), 'End date': datetime.date(2022, 5, 7), 'Allocated budget': Decimal('20000.00'), 'Balance due': Decimal('20000.00'), 'Grant scheme': 'Big Expeditions', 'Name of PI': 'John Smith', 'Gender': 'N/A', 'Career stage': 'N/A', 'Geographic focus': 'Arctic', 'Location': 'Somewhere in the world', 'Keywords': 'Algae', 'Status': 'Ongoing' }])
def test_get_one_project_ok(self): database_population.create_project() response = self._client_management.get( reverse('logged-reporting-projects_information-excel')) self.assertEqual(response.status_code, 200) self.assertTrue(response['content-disposition'].endswith('.xlsx"')) self.assertGreaterEqual(int(response['content-length']), 5800)
def test_get(self): client = database_population.create_management_logged_client() database_population.create_project('TEST-2021-001', 'Test project') response = client.get(reverse('logged-project-list')) self.assertEqual(response.status_code, 200) self.assertContains(response, 'TEST-2021-001') self.assertContains(response, 'Test project')
def data_two_projects(self): project1 = database_population.create_project() organisation_name = OrganisationName.objects.create( name='Some organisation') project1.principal_investigator.organisation_names.add( organisation_name) project2 = create_project_with_invoices() self.assertEqual(ProjectsBalanceExcel.headers(), [ 'Key', 'Signed date', 'Organisation', 'Title', 'Start date', 'End date', 'Allocated budget', 'Balance due' ]) self.assertEqual(ProjectsBalanceExcel.rows(), [{ 'Key': 'SPI-2020-001', 'Signed date': 'No grant agreement attached', 'Organisation': 'Some organisation', 'Title': 'This is a test project', 'Start date': datetime.date(2020, 1, 10), 'End date': datetime.date(2022, 5, 7), 'Allocated budget': Decimal('20000.00'), 'Balance due': Decimal('20000.00') }, { 'Key': 'SPI-2020-002', 'Signed date': '04/01/2020', 'Organisation': '', 'Title': 'Second test', 'Start date': datetime.date(2020, 1, 10), 'End date': datetime.date(2022, 5, 7), 'Allocated budget': Decimal('15000.00'), 'Balance due': Decimal('13500.00') }])
def data_one_project(self): database_population.create_project() self.assertEqual(ProjectsBalanceExcel.headers(), [ 'Key', 'Signed date', 'Organisation', 'Title', 'Start date', 'End date', 'Allocated budget', 'Balance due' ]) self.assertEqual(ProjectsBalanceExcel.rows(), [{ 'Key': 'SPI-2020-001', 'Signed date': 'No grant agreement attached', 'Organisation': '', 'Title': 'This is a test project', 'Start date': datetime.date(2020, 1, 10), 'End date': datetime.date(2022, 5, 7), 'Allocated budget': Decimal('20000.00'), 'Balance due': Decimal('20000.00') }])
def data_two_projects(self): project1 = database_population.create_project() organisation_name = OrganisationName.objects.create( name='Some organisation') project1.principal_investigator.organisation_names.add( organisation_name) project2 = create_project_with_invoices() self.assertEqual(ProjectsAllInformationExcel._headers(), [ 'Key', 'Grant scheme', 'Name of PI', 'Organisation', 'Gender', 'Career stage', 'Geographic focus', 'Location', 'Keywords', 'Title', 'Signed date', 'Start date', 'End date', 'Allocated budget', 'Balance due', 'Status' ]) self.assertEqual(ProjectsAllInformationExcel._rows(), [{ 'Key': 'SPI-2020-001', 'Signed date': 'No grant agreement attached', 'Organisation': 'Some organisation', 'Title': 'This is a test project', 'Start date': datetime.date(2020, 1, 10), 'End date': datetime.date(2022, 5, 7), 'Allocated budget': Decimal('20000.00'), 'Balance due': Decimal('20000.00'), 'Grant scheme': 'Big Expeditions', 'Name of PI': 'John Smith', 'Gender': 'N/A', 'Career stage': 'N/A', 'Geographic focus': 'Arctic', 'Location': 'Somewhere in the world', 'Keywords': 'Algae', 'Status': 'Ongoing' }, { 'Key': 'SPI-2020-002', 'Signed date': datetime.date(2020, 1, 4), 'Organisation': '', 'Title': 'Second test', 'Start date': datetime.date(2020, 1, 10), 'End date': datetime.date(2022, 5, 7), 'Allocated budget': Decimal('15000.00'), 'Balance due': Decimal('13500.00'), 'Grant scheme': 'Big Expeditions', 'Name of PI': 'James Alan', 'Gender': 'N/A', 'Career stage': 'N/A', 'Geographic focus': 'Arctic', 'Location': 'Somewhere in the world', 'Keywords': 'Algae', 'Status': 'Ongoing' }])
def test_get_two_projects_ok(self): project1 = database_population.create_project() organisation_name = OrganisationName.objects.create( name='Some organisation') project1.principal_investigator.organisation_names.add( organisation_name) project2 = create_project_with_invoices() response = self._client_management.get( reverse('logged-reporting-projects_information-excel')) self.assertEqual(response.status_code, 200) self.assertTrue(response['content-disposition'].endswith('.xlsx"')) self.assertGreaterEqual(int(response['content-length']), 5900)
def test_get_one_medium(self): project = database_population.create_project() medium = database_population.create_medium(project) response = self._client.get( f'{reverse("api-list-media-view")}?modified_since={quote_plus("2017-01-28T21:00:00+00:00")}', HTTP_ApiKey=settings.API_SECRET_KEY ) self.assertEqual(response.status_code, 200) json_body = json.loads(response.content) self.assertEqual(len(json_body), 1) medium_json = json_body[0] self.assertEqual(medium_json['license'], None) self.assertEqual(medium_json['copyright'], medium.copyright) self.assertEqual(medium_json['file_md5'], medium.file_md5) self.assertEqual(medium_json['descriptive_text'], medium.descriptive_text)
def create_project_with_invoices(): project2 = database_population.create_project(key='SPI-2020-002', title='Second test') principal_investigator = database_population.create_person_position( first_name='James', surname='Alan', orcid=None) project2.principal_investigator = principal_investigator project2.allocated_budget = 15_000 project2.save() # This one is not paid yet: Invoice.objects.create(project=project2, sent_for_payment_date=datetime.date(2021, 4, 5), amount=1_000) # This one it is paid: Invoice.objects.create(project=project2, sent_for_payment_date=datetime.date(2021, 4, 5), paid_date=datetime.date(2021, 4, 5), amount=1_500) grant_agreement = GrantAgreement.objects.create( project=project2, signed_date=datetime.datetime(2020, 1, 4))
def setUp(self): self._project = database_population.create_project()
def setUp(self): self._project = database_population.create_project() self._user = database_population.create_management_user() self._lay_summary_original_type = database_population.create_lay_summary_original( )
def setUp(self): self._project = database_population.create_project() self._user = database_population.create_management_user()
def setUp(self): self._project = database_population.create_project() self._client_management = database_population.create_management_logged_client()