コード例 #1
0
 def test_removeLecture(self):
     """
         Test adds a lecture to an existing course, verifies
         that it is there, and then removes it, and verifies
         that it is not there.
     """
     self.test_addLecture()
     TestCase.assertTrue(
         self,
         self.myCourseCatalog.removeLectureFromCourse(
             "A", "SOEN", 341, "Fall"),
         "The lecture was not successfully removed")
     TestCase.assertEqual(
         self,
         len(
             self.myCourseCatalog.searchCoursesThroughPartialName("SOEN341")
             [0].lecture_set.all()), 0,
         "The lecture was not successfully removed")
     TestCase.assertEqual(
         self,
         len(
             self.myCourseCatalog.searchCoursesThroughPartialName("SOEN341")
             [0].tutorial_set.all()), 0,
         "The lecture was not successfully removed")
     TestCase.assertEqual(
         self,
         len(
             self.myCourseCatalog.searchCoursesThroughPartialName("SOEN341")
             [0].lab_set.all()), 0,
         "The lecture was not successfully removed")
コード例 #2
0
def assert_examine_response(test_case: TestCase, response, true_data) -> None:
    if response.data.get('id', False):
        raise AttributeError(
            "Please remove id before passing data into this function")

    test_case.assertTrue(response.data.pop('examiner_approval_date') is None)
    test_case.assertTrue(response.data.pop('nominator'))

    test_case.assertEqual(response.data, true_data)
コード例 #3
0
ファイル: gmm_view.py プロジェクト: CosmosTUe/Cosmos
def assert_file_exists(test: TestCase, file_name: str):
    url = f"/media/gmm/{file_name}"
    file_path = f"{settings.MEDIA_ROOT}/gmm/{file_name}"

    response = test.client.get(url)
    test.assertEqual(200, response.status_code, "endpoint shall work")
    test.assertTrue(
        FileObject.objects.filter(name=file_name).exists(),
        "file shall be in DB")
    test.assertTrue(os.path.exists(file_path), "file in filesystem")
コード例 #4
0
def assert_supervise_response(test_case: TestCase, response,
                              true_data) -> None:
    if response.data.get('id', False):
        raise AttributeError(
            "Please remove id before passing data into this function")

    # Not check-able
    test_case.assertTrue(response.data.pop('supervisor_approval_date') is None)
    test_case.assertTrue(response.data.pop('nominator'))

    # We'll test approval in other tests
    test_case.assertFalse(response.data.pop('is_supervisor_approved'))

    test_case.assertEqual(response.data, true_data)
コード例 #5
0
def test_inc_assoc(testcase: TestCase, ass_add: pd.DataFrame,
                   ass_backup: pd.DataFrame):
    '''
    Test that the number of associations increased or equal with added 
    images.

    Parameters
    ----------
    testcase : class
        Test class.
    ass_add : pd.DataFrame
        Associations after images were added.
    ass_backup : pd.DataFrame
        Associations before images were added.
    '''

    testcase.assertTrue(len(ass_add) >= len(ass_backup))
コード例 #6
0
 def test_removeTutorial(self):
     """
         Test adds a lecture to a course, and then a tutorial
         to that lecture, and then verifies that it is in the
         database, and then removes it and verifies that it is
         no long in the database
     """
     self.test_addTutorial()
     TestCase.assertTrue(
         self,
         self.myCourseCatalog.removeTutorialFromCourse(
             "AI", "SOEN", 341, "Fall"), "Tutorial removal not successful")
     TestCase.assertEqual(
         self,
         len(
             self.myCourseCatalog.searchCoursesThroughPartialName("SOEN341")
             [0].tutorial_set.all()), 0, "Tutorial not removed from course")
コード例 #7
0
 def test_addLecture(self):
     """
         Test attempts to add a lecture to a course
         and verifies that it is found in the database.
     """
     TestCase.assertTrue(
         self,
         self.myCourseCatalog.addLectureToCourse("A", "SOEN", 341,
                                                 "8:45:00", "10:00:00",
                                                 "--W-F--", "Fall",
                                                 "SGW H-620", False),
         "Lecture not successfully added to course")
     TestCase.assertEqual(
         self,
         len(
             self.myCourseCatalog.searchCoursesThroughPartialName("SOEN341")
             [0].lecture_set.all()), 1,
         "Lecture not successfully added to database")
コード例 #8
0
 def test_addTutorial(self):
     """
         Test attempts to add a tutorial to a lecture and
         verifies that it is found in the database.
     """
     self.test_addLecture()
     TestCase.assertTrue(
         self,
         self.myCourseCatalog.addTutorialToCourse("AI", "SOEN", 341, "Fall",
                                                  "8:45:00", "10:00:00",
                                                  "---R---", "SGW H-620",
                                                  "A"),
         "Tutorial not successfully added to course")
     TestCase.assertEqual(
         self,
         len(
             self.myCourseCatalog.searchCoursesThroughPartialName("SOEN341")
             [0].tutorial_set.all()), 1,
         "Tutorial not successfully added to lecture")
コード例 #9
0
def test_known_source(testcase: TestCase, sources: pd.DataFrame, high_sigma: float):
    '''
    Check that PSR J2129-04 is detected as a new source and has correct
    new_high_sigma.

    Parameters
    ----------
    testcase : class
        Test class.
    sources : pd.DataFrame
        The sources to search through.
    high_sigma : float
        The expected high sigma value.
    '''
    sources = sources.reset_index()
    id_match = known_source(sources)

    # check new and has correct new_high_sigma to 3 decimal places
    testcase.assertTrue(sources.loc[id_match, 'new'])
    testcase.assertTrue(
        abs(sources.loc[id_match, 'new_high_sigma'] - high_sigma) < 1e-3
    )
コード例 #10
0
def assert_contract_response(test_case: TestCase, response, true_data) -> None:
    if response.data.get('id', False):
        raise AttributeError(
            'Please remove id before passing data into this function')

    # Not check-able
    test_case.assertTrue(response.data.pop('create_date'))
    test_case.assertTrue(response.data.pop('supervise') is not None)
    test_case.assertTrue(response.data.pop('assessment') is not None)
    test_case.assertTrue(response.data.pop('was_submitted') is not None)
    test_case.assertTrue(
        response.data.pop('is_examiner_nominated') is not None)

    # Contract should at least have one supervisor, otherwise is_all_supervisors_approved
    # would be false. Contract test also does not approve any supervise relation, as such
    # is_all_supervisors_approved should always be False.
    test_case.assertFalse(response.data.pop('is_all_supervisors_approved'))

    # Contract should at least have one assessment, otherwise is_all_assessments_approved
    # would be false. Contract test also does not approve any assessment method, as such
    # is_all_assessments_approved should always be False.
    test_case.assertFalse(response.data.pop('is_all_assessments_approved'))

    test_case.assertEqual(response.data, true_data)
コード例 #11
0
ファイル: test_no_op.py プロジェクト: AlexsLemonade/refinebio
def assertRunsSuccessfully(test_case: TestCase, job: ProcessorJob) -> dict:
    final_context = no_op.no_op_processor(job.pk)
    test_case.assertTrue(final_context["success"])
    test_case.assertTrue(os.path.exists(final_context["output_file_path"]))

    test_case.assertEqual(len(final_context["samples"]), 1)
    test_case.assertEqual(len(final_context["computed_files"]), 1)

    for sample in final_context["samples"]:
        for cf in final_context["computed_files"]:
            test_case.assertTrue(cf in sample.computed_files.all())

    # Return final_context so we can perform additional checks manually
    return final_context
コード例 #12
0
def response_is_html(response, title=None):
    test = TestCase()
    test.assertTrue(response.content.startswith(b'<!DOCTYPE html>'))
    if title is not None:
        test.assertContains(response, '<title>%s</title>' % (title,))
    test.assertTrue(response.content.endswith(b'</html>'))
コード例 #13
0
ファイル: test_utilities.py プロジェクト: sbonaime/NEMO
def test_response_is_login_page(test_case: TestCase, response: Response):
    test_case.assertEqual(response.status_code, 200)
    test_case.assertTrue("login" in response.request['PATH_INFO'])
コード例 #14
0
ファイル: tests.py プロジェクト: royendgel/django-datatables
 def test_whatever(self):
     a = True
     TestCase.assertTrue(a)
コード例 #15
0
ファイル: tests.py プロジェクト: royendgel/django-datatables
 def test_whatever(self):
     a = True
     TestCase.assertTrue(a)
コード例 #16
0
def test_creation(o):
    t = make_complete_model_instance(o)
    TestCase.assertTrue(isinstance(t, o))
    TestCase.assertEqual(t.__str__(), t.title + ' (' + t.short_name + ')')