Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: John Mertic <[email protected]>
  • Loading branch information
jmertic committed Nov 14, 2024
1 parent 124fedb commit 3be7900
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lfx_landscape_tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _lookupProjectFromSlug(self, slug):
with session.get(singleSlugEndpointURL.format(slug)) as endpointResponse:
parentProject = endpointResponse.json()
if len(parentProject.get('Data')) > 0:
return parentProject.get('Data')[0]["ProjectID"]
return parentProject.get('Data')[0].get("ProjectID")

logging.getLogger().warning("Couldn't find project for slug '{}'".format(slug))

Expand All @@ -119,7 +119,7 @@ def _lookupSlugFromProject(self,project):
with session.get(singleProjectEndpointURL.format(project)) as endpointResponse:
parentProject = endpointResponse.json()
if len(parentProject.get('Data')) > 0:
return parentProject.get('Data')[0]["Slug"]
return parentProject.get('Data',[])[0].get("Slug")

logging.getLogger().warning("Couldn't find slug for project '{}'".format(project))

Expand Down
1 change: 0 additions & 1 deletion lfx_landscape_tools/tacagendaproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def loadData(self):

command = subprocess.run(self.gh_cli_call.format(gh_project_id=self.gh_project_id,gh_org=self.gh_org), shell=True, capture_output=True)
jsonProjectData = command.stdout

csvRows = []
try:
projectData = json.loads(jsonProjectData)
Expand Down
23 changes: 23 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,29 @@ def testCaptionLogoFail(self):

self.assertEqual(str(cm.exception),'Adding caption failed: this is a file')

class TestTACAgendaProjects(unittest.TestCase):

@patch('subprocess.run')
def testLoadData(self, mock_run):
mock_result = Mock()
mock_result.stdout = '{"items":[{"assignees":["carolalynn"],"content":{"body":"","number":473,"repository":"AcademySoftwareFoundation/tac","title":"D&I Working Group","type":"Issue","url":"https://github.com/AcademySoftwareFoundation/tac/issues/473"},"id":"PVTI_lADOAm6tAs4AS_w4zgJSO7E","labels":["2-annual-review"],"landscape URL":"https://landscape.aswf.io/card-mode?project=working-group&selected=d-i-working-group","pCC Project ID":"a092M00001KWjDZQA1","pCC TSC Committee ID":"ac9cbe7f-0dc8-4be0-b404-cb7b9b0bb22f","repository":"https://github.com/AcademySoftwareFoundation/tac","scheduled Date":"2024-12-11","status":"Next Meeting Agenda Items","title":"D&I Working Group"}],"totalCount":32}'
mock_run.return_value = mock_result

config = Config()
config.slug = 'aswf'
config.projectsAddTechnologySector = True
config.projectsAddIndustrySector = True
config.projectsAddPMOManagedStatus = True
config.projectsAddParentProject = True
config.artworkRepoUrl = "https://artwork.aswf.io/projects/{slug}"
config.tacAgendaProjectUrl = "https://github.com/orgs/AcademySoftwareFoundation/projects/19/views/1"
members = TACAgendaProject(config=config,loadData=False)

with unittest.mock.patch('requests_cache.CachedSession', requests.Session):
members.loadData()
self.assertEqual(members.members[0].orgname,"D&I Working Group")
self.assertEqual(members.members[0].crunchbase,"https://www.crunchbase.com/organization/linux-foundation")

class TestLFXProjects(unittest.TestCase):

def testFindBySlug(self):
Expand Down

0 comments on commit 3be7900

Please sign in to comment.