Exemplo n.º 1
0
 def test_daily_offset_due_tomorrow(self):
     daily = qautils.create_frequency(name="d",
                                      slug="d",
                                      interval=1,
                                      save=False)
     seven_am_today = self.make_dt(timezone.datetime(2018, 11, 20, 7, 0))
     seven_am_tmrw = self.make_dt(timezone.datetime(2018, 11, 21, 7, 0))
     assert scheduling.calc_due_date(seven_am_today, seven_am_tmrw,
                                     daily).date() == seven_am_tmrw.date()
Exemplo n.º 2
0
    def setUp(self):
        self.user = create_user(is_superuser=True, uname='user', pwd='pwd')
        self.client.login(username='******', password='******')

        self.u_1 = qa_utils.create_unit()
        self.u_2 = qa_utils.create_unit()
        self.f_1 = qa_utils.create_frequency()
        self.f_2 = qa_utils.create_frequency()
        self.tl_1 = qa_utils.create_test_list()
        self.tl_2 = qa_utils.create_test_list()
        self.t_1 = qa_utils.create_test()
        self.t_2 = qa_utils.create_test()
        qa_utils.create_test_list_membership(test_list=self.tl_1, test=self.t_1)
        qa_utils.create_test_list_membership(test_list=self.tl_1, test=self.t_2)

        self.g_1 = create_group()
        self.g_2 = create_group()

        self.tl_ct = ContentType.objects.get(model='testlist')
        self.tlc_ct = ContentType.objects.get(model='testlistcycle')
        self.utc_1 = qa_utils.create_unit_test_collection(
            unit=self.u_1, test_collection=self.tl_1, assigned_to=self.g_1, frequency=self.f_1
        )
        self.utc_2 = qa_utils.create_unit_test_collection(
            unit=self.u_2, active=False, assigned_to=self.g_2, frequency=self.f_2
        )

        self.url_list = reverse(
            'admin:%s_%s_changelist' % (
                qa_models.UnitTestCollection._meta.app_label, qa_models.UnitTestCollection._meta.model_name
            )
        )
        self.url_add = reverse(
            'admin:%s_%s_add' % (
                qa_models.UnitTestCollection._meta.app_label, qa_models.UnitTestCollection._meta.model_name
            )
        )
        self.url_change = reverse(
            'admin:%s_%s_change' % (
                qa_models.UnitTestCollection._meta.app_label, qa_models.UnitTestCollection._meta.model_name
            ),
            args=[self.utc_1.id]
        )
Exemplo n.º 3
0
 def test_monthly_offset(self):
     """Monthly frequency when performed today should result in due date 28 days in future"""
     monthly = qautils.create_frequency(name="d",
                                        slug="d",
                                        interval=28,
                                        save=False)
     seven_am_today = self.make_dt(timezone.datetime(2018, 11, 20, 7, 0))
     due_date = timezone.now()  # arbitrary
     seven_am_4wks = self.make_dt(timezone.datetime(2018, 12, 18, 7, 0))
     assert scheduling.calc_due_date(
         seven_am_today, due_date, monthly).date() == seven_am_4wks.date()
Exemplo n.º 4
0
 def test_daily_offset_due_yesterday(self):
     """Daily frequency when performed today should result in due date one day in future"""
     daily = qautils.create_frequency(name="d",
                                      slug="d",
                                      interval=1,
                                      save=False)
     seven_am_today = self.make_dt(timezone.datetime(2018, 11, 20, 7, 0))
     due = self.make_dt(timezone.datetime(2018, 11, 19, 7, 0))
     seven_am_tmrw = self.make_dt(timezone.datetime(2018, 11, 21, 7, 0))
     assert scheduling.calc_due_date(seven_am_today, due,
                                     daily).date() == seven_am_tmrw.date()
Exemplo n.º 5
0
 def test_daily_offset_due_today_after_due_time(self):
     """Daily frequency when performed today should result in due date one day in future"""
     daily = qautils.create_frequency(name="d",
                                      slug="d",
                                      interval=1,
                                      save=False)
     eight_am_today = self.make_dt(timezone.datetime(2018, 11, 20, 8, 0))
     due = eight_am_today - timezone.timedelta(hours=1)
     eight_am_tmrw = self.make_dt(timezone.datetime(2018, 11, 21, 8, 0))
     assert scheduling.calc_due_date(eight_am_today, due,
                                     daily).date() == eight_am_tmrw.date()
Exemplo n.º 6
0
    def test_admin_unittestcollection(self):

        if not utils.exists('auth', 'Group', 'name', objects['Group']['name']):
            create_group(name=objects['Group']['name'])

        if not utils.exists('units', 'Unit', 'name',
                            objects['Modality']['name']):
            utils.create_unit(name=objects['Modality']['name'],
                              number=objects['Unit']['number'])

        if not utils.exists('qa', 'Frequency', 'name',
                            objects['Frequency']['name']):
            utils.create_frequency(name=objects['Frequency']['name'])

        if not utils.exists('qa', 'TestList', 'name',
                            objects['TestList']['name']):
            utils.create_test_list(name=objects['TestList']['name'])

        self.load_admin()
        self.click_by_link_text("Assign Test Lists to Units")
        self.click_by_link_text('ADD UNIT TEST COLLECTION')
        self.wait.until(e_c.presence_of_element_located((By.ID, 'id_unit')))

        self.select_by_index("id_unit", 1)
        self.select_by_index("id_frequency", 1)
        self.select_by_index("id_assigned_to", 0)
        self.select_by_index("id_content_type", 1)
        self.driver.find_element_by_css_selector(
            '#id_visible_to_from > option:nth-child(1)').click()
        self.driver.find_element_by_css_selector(
            '#id_visible_to_add_link').click()

        time.sleep(2)

        self.driver.find_element_by_id(
            'select2-generic_object_id-container').click()
        self.driver.find_element_by_id(
            'select2-generic_object_id-container').click()
        self.driver.find_element_by_name('_save').click()
        self.wait_for_success()
Exemplo n.º 7
0
 def test_annual_offset(self):
     """Annual frequency when performed today should result in due date 300 days in future"""
     annual = qautils.create_frequency(name="d",
                                       slug="d",
                                       interval=300,
                                       save=False)
     seven_am_today = self.make_dt(timezone.datetime(2018, 11, 20, 7, 0))
     due_date = self.make_dt(timezone.datetime(2018, 12, 20, 7,
                                               0))  # arbitrary
     seven_am_300_days = self.make_dt(timezone.datetime(2019, 9, 16, 7, 0))
     assert scheduling.calc_due_date(
         seven_am_today, due_date,
         annual).date() == seven_am_300_days.date()
Exemplo n.º 8
0
    def setUp(self):
        self.user = create_user(is_superuser=True, uname='user', pwd='pwd')
        self.client.login(username='******', password='******')

        self.t_1 = qa_utils.create_test()
        self.t_2 = qa_utils.create_test()
        self.u_1 = qa_utils.create_unit()
        self.f_1 = qa_utils.create_frequency()
        self.tl_1 = qa_utils.create_test_list()
        self.utc_1 = qa_utils.create_unit_test_collection(test_collection=self.tl_1, unit=self.u_1)
        self.utc_2 = qa_utils.create_unit_test_collection(test_collection=self.tl_1, frequency=self.f_1)

        qa_utils.create_test_list_membership(test_list=self.tl_1, test=self.t_2, order=0)

        self.sublist = qa_utils.create_sublist(parent_test_list=self.tl_1)

        self.url_add = reverse(
            'admin:%s_%s_add' % (qa_models.TestList._meta.app_label, qa_models.TestList._meta.model_name)
        )
        self.url_list = reverse(
            'admin:%s_%s_changelist' % (qa_models.TestList._meta.app_label, qa_models.TestList._meta.model_name)
        )
        self.url_change = reverse(
            'admin:%s_%s_change' % (qa_models.TestList._meta.app_label, qa_models.TestList._meta.model_name),
            args=[self.tl_1.id]
        )

        self.data = {
            'name': 'testing_sublists',
            'warning_message': 'erroR',
            'javascript': 'alert("subs!")',
            'slug': 'testing_sublists',
            'description': 'description',

            'attachment_set-MAX_NUM_FORMS': 10,
            'attachment_set-INITIAL_FORMS': 0,
            'attachment_set-MIN_NUM_FORMS': 0,
            'attachment_set-TOTAL_FORMS': 1,
            'attachment_set-0-testlist': '',
            'attachment_set-0-id': '',
            'attachment_set-0-comment': 'Testing',
            'attachment_set-0-attachment': '',

            'children-INITIAL_FORMS': 0,
            'children-MIN_NUM_FORMS': 0,
            'children-MAX_NUM_FORMS': 10,
            'children-TOTAL_FORMS': 1,
            'children-0-order': 1,
            'children-0-child': self.tl_1.id,
            'children-0-parent': '',
            'children-0-id': '',

            'testlistmembership_set-MIN_NUM_FORMS': 0,
            'testlistmembership_set-INITIAL_FORMS': 0,
            'testlistmembership_set-MAX_NUM_FORMS': 10,
            'testlistmembership_set-TOTAL_FORMS': 1,
            'testlistmembership_set-0-test_list': '',
            'testlistmembership_set-0-id': '',
            'testlistmembership_set-0-order': 0,
            'testlistmembership_set-0-test': self.t_1.id
        }