Skip to content

Commit

Permalink
hpv data
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaymudholkar1 committed Oct 1, 2024
1 parent 5323197 commit f55b37c
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 18 deletions.
78 changes: 78 additions & 0 deletions libs/api_ops.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import requests
from constants import api_constants


class api_operations:
@staticmethod
def api_get(endpoint, header, param):
if header is None and param is None:
resp = requests.get(url=endpoint)
elif header is not None and param is None:
resp = requests.get(url=endpoint, headers=header)
elif header is None and param is not None:
resp = requests.get(url=endpoint, params=param)
else:
resp = requests.get(url=endpoint, params=param, headers=header)
assert api_operations.__verify_response_code(resp.status_code), f"API GET failed for {endpoint}."
return resp

@staticmethod
def api_post(endpoint, header, payload, param):
resp = None
if header is None and payload is None and param is None:
resp = requests.post(url=endpoint)
elif header is not None and payload is None and param is None:
resp = requests.post(url=endpoint, headers=header)
elif header is not None and payload is None and param is not None:
resp = requests.post(url=endpoint, headers=header, params=param)
elif header is None and payload is not None and param is None:
resp = requests.post(url=endpoint, json=payload)
elif header is None and payload is not None and param is not None:
resp = requests.post(url=endpoint, json=payload, params=param)
elif header is not None and payload is not None and param is None:
resp = requests.post(url=endpoint, json=payload, headers=header)
elif header is not None and payload is not None and param is not None:
resp = requests.post(url=endpoint, json=payload, headers=header, params=param)
assert api_operations.__verify_response_code(resp.status_code), f"API POST failed for {endpoint}."
return resp

@staticmethod
def api_put(endpoint, header, payload, param):
resp = None
if header is None and payload is None and param is None:
resp = requests.put(url=endpoint)
elif header is not None and payload is None and param is None:
resp = requests.put(url=endpoint, headers=header)
elif header is not None and payload is None and param is not None:
resp = requests.put(url=endpoint, headers=header, params=param)
elif header is None and payload is not None and param is None:
resp = requests.put(url=endpoint, json=payload)
elif header is None and payload is not None and param is not None:
resp = requests.put(url=endpoint, json=payload, params=param)
elif header is not None and payload is not None and param is None:
resp = requests.put(url=endpoint, json=payload, headers=header)
elif header is not None and payload is not None and param is not None:
resp = requests.put(url=endpoint, json=payload, headers=header, params=param)
assert api_operations.__verify_response_code(resp.status_code), f"API PUT failed for {endpoint}."
return resp

@staticmethod
def api_delete(endpoint, header, param):
if header is None and param is None:
resp = requests.delete(url=endpoint)
elif header is not None and param is None:
resp = requests.delete(url=endpoint, headers=header)
elif header is None and param is not None:
resp = requests.delete(url=endpoint, params=param)
else:
resp = requests.delete(url=endpoint, headers=header, params=param)
assert api_operations.__verify_response_code(resp.status_code), f"API DELETE failed for {endpoint}."
return resp

@staticmethod
def __verify_response_code(response_code: int) -> bool:
return (
True
if api_constants.API_SUCCESS_STATUS_CODE_MIN <= response_code <= api_constants.API_SUCCESS_STATUS_CODE_MAX
else False
)
5 changes: 5 additions & 0 deletions libs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ class file_mode:
READ = "r"
WRITE = "w"
APPEND = "a"


class api_constants:
API_SUCCESS_STATUS_CODE_MIN = 200
API_SUCCESS_STATUS_CODE_MAX = 299
4 changes: 3 additions & 1 deletion libs/file_ops.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
from os import path
from libs.constants import file_mode

import pandas as pd

from libs.constants import file_mode


class file_operations:

Expand Down
6 changes: 4 additions & 2 deletions libs/playwright_ops.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

from playwright.sync_api import expect
from libs.constants import object_properties, actions, screenshot_types

from libs import CurrentExecution
import os
from libs.constants import actions, object_properties, screenshot_types


class playwright_operations:
Expand Down
21 changes: 13 additions & 8 deletions pages/pg_programmes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from libs import playwright_ops
from libs import CurrentExecution, file_ops, playwright_ops, testdata_ops
from libs.constants import actions
from libs import CurrentExecution
from libs import testdata_ops
from libs import file_ops


class pg_programmes:
Expand Down Expand Up @@ -62,14 +59,22 @@ def choose_file_vaccination_records(self, file_path: str):
value=file_path,
)

def upload_vaccination_records(self, template_path: str):
_data_file_path = self.tdo.create_file_from_template(template_path=template_path)
_input_df = self.fo.read_file_to_df(file_path=_data_file_path)
def upload_hpv_vaccination_records(self, input_file_path: str):
self.click_HPV()
self.click_Imports()
self.click_ImportRecords()
self.select_VaccinationRecords()
self.click_Continue()
self.choose_file_vaccination_records(file_path=_data_file_path)
self.choose_file_vaccination_records(file_path=input_file_path)
self.click_Continue()
self.click_UploadRecords()

def upload_hpv_child_records(self, input_file_path: str):
self.click_HPV()
self.click_Imports()
self.click_ImportRecords()
self.select_ChildRecords()
self.click_Continue()
self.choose_file_child_records(file_path=input_file_path)
self.click_Continue()
self.click_UploadRecords()
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
asttokens==2.4.1
certifi==2024.8.30
charset-normalizer==3.3.2
colorama==0.4.6
comm==0.2.2
debugpy==1.8.5
decorator==5.1.1
exceptiongroup==1.2.2
executing==2.1.0
greenlet==3.0.3
idna==3.10
iniconfig==2.0.0
ipykernel==6.29.5
ipython==8.27.0
Expand Down Expand Up @@ -34,11 +37,13 @@ python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.2
pyzmq==26.2.0
requests==2.32.3
six==1.16.0
stack-data==0.6.3
tomli==2.0.1
tornado==6.4.1
traitlets==5.14.3
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.2.3
wcwidth==0.2.13
3 changes: 0 additions & 3 deletions test_data/hpv/file1.csv

This file was deleted.

17 changes: 17 additions & 0 deletions test_data/hpv/hpv_positive_full.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
TEST_DESC_IGNORED,ORGANISATION_CODE,SCHOOL_URN,SCHOOL_NAME,NHS_NUMBER,PERSON_FORENAME,PERSON_SURNAME,PERSON_DOB,PERSON_GENDER_CODE,PERSON_POSTCODE,DATE_OF_VACCINATION,VACCINE_GIVEN,BATCH_NUMBER,BATCH_EXPIRY_DATE,ANATOMICAL_SITE,DOSE_SEQUENCE,LOCAL_PATIENT_ID,LOCAL_PATIENT_ID_URI,CARE_SETTING
P_Gardasil9,R1L,110158,Eton College,9729852545,BERT,BOYES,20100811,Male,DN9 1PB,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1
P_Gardasil,R1L,110158,Eton College,9650974318,BOB,JERMEY,20100819,Male,DN38 6JP,20240514,Gardasil,123013325,20220730,Left Thigh,2,LocalPatient3,www.LocalPatient3,1
P_Cervarix,R1L,110158,Eton College,5990960948,MURRAY,MARQUARDT,20100808,Male,N8 7RE,20240514,Cervarix,123013325,20220730,Left Thigh,3,LocalPatient3,www.LocalPatient3,1
P_Gardasil9,R1L,888888,Test-Auto School,9461217986,SHEENA,HART-DAVIS,20100818,Female,HD9 2DD,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1
P_Gardasil,R1L,999999,Homeschooled,9448251165,ANDRIANA,MACLULICH,20100813,Female,DN17 1UE,20240514,Gardasil,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1
P_Cervarix,R1L,110158,Eton College,9490189804,VISHALA,MOKATE,20100817,Female,LA22 9SJ,20240514,Cervarix,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1
P_NFA,R1L,110158,Eton College,9694580307,LERON,KUFAKI,20100811,Male,ZZ99 3VZ,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1
P_Add_Not_Known,R1L,110158,Eton College,9694580307,LERON,KUFAKI,20100811,Male,ZZ99 3WZ,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1
P_Add_Not_Known2,R1L,110158,Eton College,9694580307,LERON,KUFAKI,20100811,Male,ZZ99 3CZ,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1
P_Site_LB,R1L,110158,Eton College,9694580307,LERON,KUFAKI,20100811,Male,DN34 4SE,20240514,Gardasil9,123013325,20220730,Left Buttock,1,LocalPatient3,www.LocalPatient3,1
P_Site_RB,R1L,110158,Eton College,9460860354,MATTIE,MERRIGAN,20100831,Male,TS8 9EF,20240514,Gardasil9,123013325,20220730,Right Buttock,1,LocalPatient3,www.LocalPatient3,1
P_Site_LT,R1L,110158,Eton College,9651751703,SARA,NOYES,20100829,Not Known,HU5 3SG,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1
P_Site_N_Should_Fail,R1L,110158,Eton College,9726851416,NAOMI,DILLON,20100818,Female,BH25 6ST,20240514,Gardasil9,123013325,20220730,Nasal,1,LocalPatient3,www.LocalPatient3,1
P_Site_LUA,R1L,110158,Eton College,5991336512,HARLEY,PHILLIPS,20100821,Female,ZZ99 3AZ,20240514,Gardasil9,123013325,20220730,Left Upper Arm,1,LocalPatient3,www.LocalPatient3,1
P_Site_RUA,R1L,110158,Eton College,9454468014,GIDEON,CREAN,20100830,Male,NE39 1AD,20240514,Gardasil9,123013325,20220730,Right Upper Arm,1,LocalPatient3,www.LocalPatient3,1
P_Site_RT,R1L,110158,Eton College,9686147837,JEFF,GREENE,20100808,Male,SK16 4HT,20240514,Gardasil9,123013325,20220730,Right Thigh,1,LocalPatient3,www.LocalPatient3,1
7 changes: 3 additions & 4 deletions tests/test_2_reg_file_upload.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from pages import pg_login
from pages import pg_home
from pages import pg_programmes

from pages import pg_home, pg_login, pg_programmes


class Test_Regression:
Expand All @@ -14,4 +13,4 @@ class Test_Regression:
def test_reg_file_upload(self, create_browser_page):
self.login_page.perform_login()
self.home_page.click_programmes()
self.programmes_page.upload_vaccination_records(template_path="test_data/hpv/file1.csv")
self.programmes_page.upload_hpv_vaccination_records(input_file_path="test_data/hpv/hpv_positive_full.csv")

0 comments on commit f55b37c

Please sign in to comment.