def test_get_tool_file_data_returns_None_when_no_json(self, mock_urlopen): self.mock_with_example_config(mock_urlopen) project = GiraffeProject() mock_urlopen.return_value = io.BytesIO(bytes('not json', encoding="utf-8")) random_name = random_id() random_filename = random_id() project.config = { 'tools': { random_name: { 'file': [f'GIRAFFE/{random_filename}'] } } } self.assertEqual(None, project.get_tool_file_data(random_name))
def test_get_tool_file_data_returns_None_when_no_json(self, mock_urlopen): self.mock_with_example_config(mock_urlopen) project = GiraffeProject() mock_urlopen.return_value = io.BytesIO( bytes('not json', encoding="utf-8")) random_name = random_id() random_filename = random_id() project.config = { 'tools': { random_name: { 'file': [f'GIRAFFE/{random_filename}'] } } } self.assertEqual(None, project.get_tool_file_data(random_name))
def test_local_avatar_url(self): settings.BASE_URL = "http://test/" id = random_id() profile = Profile(handle=id) self.assertEqual( f"http://test/funding/avatar?repo={profile.github_url}&v=3", profile.local_avatar_url)
def test_local_avatar_url(self): settings.BASE_URL = 'http://test/' id = random_id() profile = Profile(handle=id) self.assertEqual( f"http://test/funding/avatar?repo={profile.github_url}&v=3", profile.local_avatar_url )
def test_tools_set_from_config(self, mock_urlopen): self.mock_with_example_config(mock_urlopen) project = GiraffeProject(ghuser='******', ghrepo='repo', ghbranch='branch') random_name = random_id() project.config = { 'tools': { random_name: { 'file': [f'GIRAFFE/literallyanything'] } } } tools = project.tools self.assertEqual([[random_name, f'/user/repo/branch/{random_name}']], tools)
def test_tools_set_from_config(self, mock_urlopen): self.mock_with_example_config(mock_urlopen) project = GiraffeProject( ghuser='******', ghrepo='repo', ghbranch='branch' ) random_name = random_id() project.config = { 'tools': { random_name: { 'file': [f'GIRAFFE/literallyanything'] } } } tools = project.tools self.assertEqual([[ random_name, f'/gh/user/repo/branch/{random_name}' ]], tools)
def test_github_url(self): id = random_id() profile = Profile(handle=id) self.assertEqual(f"https://github.com/{id}", profile.github_url)