def create_test_slice(test):
    
    add_test_aggregate_to_project(test)
    
    test.client.login(username=test.u2.username, password="******")
    threadlocals.push_frame(user=test.u2)

    # create the slice
    Slice.objects.all().delete()
    
    expiration = datetime.now() + timedelta(days=settings.MAX_SLICE_LIFE - 5)
    
    test_get_and_post_form(
        client=test.client,
        url=Slice.get_create_url(proj_id=test.project.id),
        params={
            "name": "slice name",
            "description": "slice description",
            "expiration_date_0": "%s" % expiration.date(),
            "expiration_date_1": expiration.time().strftime("%H:%m:%S"),
        },
    )
    test.slice = Slice.objects.all()[0]

    test.client.logout()
    threadlocals.pop_frame()
Beispiel #2
0
def create_test_slice(test):

    add_test_aggregate_to_project(test)

    test.client.login(username=test.u2.username, password="******")
    threadlocals.push_frame(user=test.u2)

    # create the slice
    Slice.objects.all().delete()

    expiration = datetime.now() + timedelta(days=settings.MAX_SLICE_LIFE - 5)

    test_get_and_post_form(
        client=test.client,
        url=Slice.get_create_url(proj_id=test.project.id),
        params={
            "name": "slice name",
            "description": "slice description",
            "expiration_date_0": "%s" % expiration.date(),
            "expiration_date_1": expiration.time().strftime("%H:%m:%S"),
        },
    )
    test.slice = Slice.objects.all()[0]

    test.client.logout()
    threadlocals.pop_frame()
Beispiel #3
0
    def test_slice_expiration_form(self):
        add_test_aggregate_to_project(self)

        self.client.login(username=self.u2.username, password="******")
        threadlocals.push_frame(user=self.u2)

        expiration = datetime.now() \
            + timedelta(days=settings.MAX_SLICE_LIFE + 5)

        response = test_get_and_post_form(
            client=self.client,
            url=Slice.get_create_url(proj_id=self.project.id),
            params={
                "name": "slice name",
                "description": "slice description",
                "expiration_date_0": "%s" % expiration.date(),
                "expiration_date_1": expiration.time().strftime("%H:%m:%S"),
            },
        )

        self.assertContains(
            response,
            "The entered date is too late. Maximum is",
        )

        response = test_get_and_post_form(
            client=self.client,
            url=Slice.get_create_url(proj_id=self.project.id),
            params={
                "name": "slice name",
                "description": "slice description",
                "expiration_date_0": "xyaz",
                "expiration_date_1": "%s" % expiration.time(),
            },
        )

        self.assertContains(
            response,
            "Enter a valid date",
        )

        self.client.logout()
        threadlocals.pop_frame()
    def test_slice_expiration_form(self):
        add_test_aggregate_to_project(self)
        
        self.client.login(
            username=self.u2.username, password="******")
        threadlocals.push_frame(user=self.u2)
        
        expiration = datetime.now() \
            + timedelta(days=settings.MAX_SLICE_LIFE + 5)
        
        response = test_get_and_post_form(
            client=self.client,
            url=Slice.get_create_url(proj_id=self.project.id),
            params={
                "name": "slice name",
                "description": "slice description",
                "expiration_date_0": "%s" % expiration.date(),
                "expiration_date_1": expiration.time().strftime("%H:%m:%S"),
            },
        )
        
        self.assertContains(
            response, "The entered date is too late. Maximum is",
        )
        
        response = test_get_and_post_form(
            client=self.client,
            url=Slice.get_create_url(proj_id=self.project.id),
            params={
                "name": "slice name",
                "description": "slice description",
                "expiration_date_0": "xyaz",
                "expiration_date_1": "%s" % expiration.time(),
            },
        )
        
        self.assertContains(
            response, "Enter a valid date",
        )

        self.client.logout()
        threadlocals.pop_frame()