Exemplo n.º 1
0
    def test_change_solution(self, product: Product):
        solution = ReleaseInfosSolution()

        product.release_infos = HistoricalReleases([
            Release(date(2020, 1, 2), Price(12000)),
            Release(date(2023, 2, 2), Price(12000)),
            Release(date(2028, 1, 2), Price(12000)),
        ])
        product.release_infos.sort()

        p_m = ProductModel.create(
            name="foo",
            release_infos=[
                ProductReleaseInfo(initial_release_date=date(2020, 1, 2),
                                   price=12000),
                ProductReleaseInfo(initial_release_date=date(2023, 2, 2),
                                   price=12000),
                ProductReleaseInfo(initial_release_date=date(2028, 2, 2),
                                   price=12000),
            ])

        solution.set_situation(ReleaseInfosStatus.CHANGE).execute(
            product_dataclass=product, product_model=p_m)

        assert ReleaseInfoHelper.compare_infos(
            product.release_infos,
            p_m.release_infos) is ReleaseInfosStatus.SAME
Exemplo n.º 2
0
    def test_stall_info_adjust_release_date(self):
        p = Product.create(name="foo")
        stall_info = ProductReleaseInfo.create(price=12960, product_id=p.id)
        delay_date = date(2021, 1, 1)

        stall_info.adjust_release_date_to(delay_date)
        assert stall_info.initial_release_date == delay_date
Exemplo n.º 3
0
    def test_get_release_date(self):
        p = Product.create(name="foo")
        info_1 = ProductReleaseInfo(price=12960, initial_release_date=date(2020, 1, 1), product_id=p.id)
        assert info_1.release_date == date(2020, 1, 1)

        info_2 = ProductReleaseInfo(price=12960, initial_release_date=date(2020, 1, 1),
                                    adjusted_release_date=date(2020, 5, 1), product_id=p.id)
        assert info_2.release_date == date(2020, 5, 1)

        info_3 = ProductReleaseInfo(price=12960, product_id=p.id)
        assert info_3.release_date == None
Exemplo n.º 4
0
    def test_release_date_could_be_brought_forward(self):
        p = Product.create(name="foo")
        init_date = ProductReleaseInfo.create(
            price=12960, initial_release_date=date(2020, 1, 1), product_id=p.id
        )

        early_date = date(2019, 12, 1)
        init_date.adjust_release_date_to(early_date)

        assert init_date.initial_release_date == date(2020, 1, 1)
        assert init_date.adjusted_release_date == early_date
Exemplo n.º 5
0
    def test_delay(self):
        release_infos = HistoricalReleases(
            [Release(date(2020, 2, 2), Price(12000))])

        p_m = ProductModel.create(
            name="foo",
            release_infos=[
                ProductReleaseInfo(initial_release_date=date(2020, 1, 2),
                                   price=12000)
            ])
        assert ReleaseInfoHelper.compare_infos(
            release_infos, p_m.release_infos) == ReleaseInfosStatus.CHANGE
Exemplo n.º 6
0
    def create_product(product_dataclass: ProductBase) -> ProductModel:
        series = Series.as_unique(name=product_dataclass.series)
        manufacturer = Company.as_unique(name=product_dataclass.manufacturer)
        category = Category.as_unique(name=product_dataclass.category)
        releaser = Company.as_unique(name=product_dataclass.releaser)
        distributer = Company.as_unique(name=product_dataclass.distributer)

        paintworks = Paintwork.multiple_as_unique(product_dataclass.paintworks)
        sculptors = Sculptor.multiple_as_unique(product_dataclass.sculptors)

        images = ProductOfficialImage.create_image_list(
            product_dataclass.images)

        release_infos: List[ProductReleaseInfo] = []
        for release in product_dataclass.release_infos:
            release_info = ProductReleaseInfo(
                price=release.price,
                initial_release_date=release.release_date,
                announced_at=release.announced_at)
            if release.price:
                release_info.tax_including = release.price.tax_including
            release_infos.append(release_info)

        product = ProductModel.create(
            url=product_dataclass.url,
            name=product_dataclass.name,
            size=product_dataclass.size,
            scale=product_dataclass.scale,
            rerelease=product_dataclass.rerelease,
            adult=product_dataclass.adult,
            copyright=product_dataclass.copyright,
            series=series,
            manufacturer=manufacturer,
            releaser=releaser,
            distributer=distributer,
            category=category,
            id_by_official=product_dataclass.maker_id,
            checksum=product_dataclass.checksum,
            jan=product_dataclass.jan,
            order_period_start=product_dataclass.order_period.start,
            order_period_end=product_dataclass.order_period.end,
            thumbnail=product_dataclass.thumbnail,
            og_image=product_dataclass.og_image,
            # relationship
            release_infos=release_infos,
            sculptors=sculptors,
            paintworks=paintworks,
            official_images=images)

        return product
Exemplo n.º 7
0
    def test_basic_info_adjust_release_date(self):
        p = Product.create(name="foo")
        info_has_init_date = ProductReleaseInfo.create(
            price=12960, initial_release_date=date(2020, 1, 1), product_id=p.id
        )
        delay_date = date(2021, 1, 1)

        info_has_init_date.adjust_release_date_to(delay_date)
        assert info_has_init_date.adjusted_release_date == delay_date

        delay_datetime = datetime(2022, 2, 2, 12)

        info_has_init_date.adjust_release_date_to(delay_datetime)
        assert info_has_init_date.adjusted_release_date == delay_datetime.date()

        with pytest.raises(AssertionError):
            info_has_init_date.adjust_release_date_to(1)
Exemplo n.º 8
0
    def test_last_release_date_was_brought_forward(self):
        release_infos = HistoricalReleases([
            Release(date(2020, 1, 2), Price(12000)),
            Release(date(2023, 2, 2), Price(12000)),
            Release(date(2028, 1, 2), Price(12000)),
        ])

        p_m = ProductModel.create(
            name="foo",
            release_infos=[
                ProductReleaseInfo(initial_release_date=date(2020, 1, 2),
                                   price=12000),
                ProductReleaseInfo(initial_release_date=date(2023, 2, 2),
                                   price=12000),
                ProductReleaseInfo(initial_release_date=date(2028, 2, 2),
                                   price=12000),
            ])

        assert ReleaseInfoHelper.compare_infos(
            release_infos, p_m.release_infos) == ReleaseInfosStatus.CHANGE
Exemplo n.º 9
0
    def test_delay_has_been_confirmed(self):
        release_infos = HistoricalReleases([
            Release(date(2019, 1, 2), Price(12000)),
            Release(date(2020, 5, 2), Price(12000)),
            Release(date(2023, 2, 2), Price(12000)),
        ])

        p_m = ProductModel.create(
            name="foo",
            release_infos=[
                ProductReleaseInfo(initial_release_date=date(2019, 1, 2),
                                   price=12000),
                ProductReleaseInfo(initial_release_date=date(2020, 2, 2),
                                   adjusted_release_date=date(2020, 5, 2),
                                   price=12000),
                ProductReleaseInfo(initial_release_date=date(2023, 2, 2),
                                   price=12000),
            ])

        assert ReleaseInfoHelper.compare_infos(
            release_infos, p_m.release_infos) == ReleaseInfosStatus.SAME
Exemplo n.º 10
0
 def test_stall_release(self):
     p = Product.create(name="foo")
     info = ProductReleaseInfo.create(price=12960, initial_release_date=date(2020, 1, 1), product_id=p.id)
     info.stall()
     assert not info.initial_release_date
Exemplo n.º 11
0
    def test_checksum_comparison(self):
        checksum = "111"
        product = Product.create(name="foo figure", url="www.foo.com", checksum="111")

        assert product.check_checksum(checksum)
Exemplo n.º 12
0
    def test_created_at_default_is_datetime(self):
        product = Product.create(name="foo")

        assert bool(product.created_at)
        assert isinstance(product.created_at, datetime)
Exemplo n.º 13
0
    def test_get_by_id(self):
        product = Product.create(name="foo figure", url="www.foo.com")

        fetched_product = Product.get_by_id(product.id)  # type: ignore
        assert fetched_product is product