当前位置: 首页>>代码示例>>Python>>正文


Python helper.TestLoadHelper类代码示例

本文整理汇总了Python中cards.tests.helper.TestLoadHelper的典型用法代码示例。如果您正苦于以下问题:Python TestLoadHelper类的具体用法?Python TestLoadHelper怎么用?Python TestLoadHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestLoadHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deck_61mountains

    def test_deck_61mountains(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        tformat = Format.objects.filter(format='Standard_2015-01-23').first()

        tdeck = Deck()
        tdeck.name = 'My Deck Name'
        tdeck.url = 'http://card.ninja/'
        tdeck.visibility = tdeck.VISIBLE
        tdeck.authorname = 'Test Dude'
        tdeck.format = tformat

        tdeck.save()

        c1 = Card.objects.filter(multiverseid=1004).first()

        dc1 = DeckCard()
        dc1.physicalcard = c1.basecard.physicalcard
        dc1.deck = tdeck
        dc1.cardcount = 61
        dc1.board = dc1.MAIN
        dc1.save()

        self.assertEquals(tdeck.get_card_count(), 61)

        self.assertTrue(tdeck.is_legal())
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:27,代码来源:tests.py

示例2: test_subtypes

    def test_subtypes(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        subtypes = (
            'Aura',
            'Human',
            'Goblin',
            'Wizard',
            'Dragon',
            'Elf',
            'Cleric',
            'Warrior',
            'Curse',
            'Soldier',
            'Sphinx',
            'Ajani',
            'Urza\'s',
            'Wurm',
            'Zombie',
            'Chandral',
            'Swamp',
            'Plains',
            'Island',
            'Forest',
            'Mountain',
            'Rat')
        dbsubtypes = Subtype.objects.all().order_by('subtype')
        self.assertEqual(dbsubtypes.count(), len(subtypes))
        for ttt in dbsubtypes:
            self.assertTrue(ttt.subtype in subtypes)
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:31,代码来源:helpertests.py

示例3: test_expansionsets

    def test_expansionsets(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        asets = ExpansionSet.objects.all()
        self.assertEquals(asets.count(), 2)
        fooset = ExpansionSet.objects.filter(abbr='FOO').first()
        self.assertEquals(fooset.releasedate, date(year=2017, month=1, day=1))
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:8,代码来源:helpertests.py

示例4: test_physicalcards

    def test_physicalcards(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        pcs = PhysicalCard.objects.all()
        self.assertEquals(pcs.count(), 5)
        for pc in pcs:
            self.assertEquals(pc.layout, pc.NORMAL)
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:8,代码来源:helpertests.py

示例5: test_tcbf

    def test_tcbf(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        mountain = BaseCard.objects.filter(name='Mountain').first().physicalcard
        island = BaseCard.objects.filter(name='Island').first().physicalcard
        formats = Format.objects.filter(formatname='Modern').order_by('-start_date')
        myform = formats[0]
        prev_form = formats[1]

        tdeck = Deck()
        tdeck.name = 'My Deck Name'
        tdeck.url = 'http://card.ninja/'
        tdeck.visibility = tdeck.VISIBLE
        tdeck.authorname = 'Test Dude'
        tdeck.format = myform

        tdeck.save()
        tdeck = Deck.objects.get(pk=tdeck.id)

        dc1 = DeckCard()
        dc1.physicalcard = island
        dc1.deck = tdeck
        dc1.cardcount = 60
        dc1.board = DeckCard.MAIN
        dc1.save()

        self.assertEquals(tdeck.get_card_count(), 60)

        tourny = Tournament(name='Test', url='http://foo.dog/', format=myform, start_date=myform.start_date, end_date=myform.start_date)
        tourny.save()

        td = TournamentDeck(tournament=tourny, deck=tdeck, place=1)
        td.save()

        FormatStat.calc_all()
        FormatCardStat.calc_all()

        fstat = FormatStat.objects.filter(format=myform).first()
        mstat = FormatCardStat.objects.filter(format=myform, physicalcard=mountain).first()
        istat = FormatCardStat.objects.filter(format=myform, physicalcard=island).first()

        cc = FormatCardStat.objects.top_cards_by_format(myform)
        self.assertEquals(cc.count(), 5, "5 cards, the basic lands, are all in this format")
        first_cc = cc.first()
        self.assertEquals(first_cc.physicalcard, island, "Top card in this format is Island")
        self.assertEquals(
            first_cc.previous_format_ids, str(
                prev_form.pk), "The previous format ids on the FormatCardStat object should be the previous format id")
        self.assertIsNone(first_cc.percentage_of_all_cards_previous(), 'None previously, so no number is returned')
        self.assertEquals(
            first_cc.percentage_of_all_cards_delta(),
            1.0,
            'There has been a change that is positive {}'.format(
                first_cc.percentage_of_all_cards_delta()))
        self.assertIsNone(first_cc.percentage_of_all_cards_perchange(), 'None previously, so no number is returned')
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:56,代码来源:stattests.py

示例6: load_card

 def load_card(self, json, name, loadhelper=True, set_abbr='BAR'):
     helper = TestLoadHelper()
     if loadhelper:
         helper.color_loader()
         helper.expansionset_example_loader()
     expset = ExpansionSet.objects.filter(abbr=set_abbr).first()
     tool = Command()
     tool.handle_card_json(json, expset)
     card = BaseCard.objects.filter(name=name).first()
     return card
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:10,代码来源:formattests.py

示例7: test_tcbf_2b

    def test_tcbf_2b(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        mountain = BaseCard.objects.filter(name='Mountain').first().physicalcard
        island = BaseCard.objects.filter(name='Island').first().physicalcard
        formats = Format.objects.filter(formatname='Modern').order_by('-start_date')
        myform = formats[0]
        prev_form = formats[1]

        for fformat in [myform, prev_form]:
            tdeck = Deck()
            tdeck.name = 'My Deck Name in {}'.format(fformat.format)
            tdeck.url = 'http://card.ninja/{}'.format(fformat.id)
            tdeck.visibility = tdeck.VISIBLE
            tdeck.authorname = 'Test Dude'
            tdeck.format = fformat

            tdeck.save()
            tdeck = Deck.objects.get(pk=tdeck.id)

            dc1 = DeckCard()
            dc1.physicalcard = island
            dc1.deck = tdeck
            dc1.cardcount = 60
            dc1.board = DeckCard.MAIN
            dc1.save()

            tourny = Tournament(
                name='Test {}'.format(
                    fformat.pk),
                url='http://foo.dog/',
                format=fformat,
                start_date=fformat.start_date,
                end_date=fformat.start_date)
            tourny.save()

            td = TournamentDeck(tournament=tourny, deck=tdeck, place=1)
            td.save()

        FormatStat.calc_all()
        FormatCardStat.calc_all()

        fstat = FormatStat.objects.filter(format=myform).first()
        mstat = FormatCardStat.objects.filter(format=myform, physicalcard=mountain).first()
        istat = FormatCardStat.objects.filter(format=myform, physicalcard=island).first()

        first_cc = istat
        self.assertEquals(first_cc.percentage_of_all_cards_previous(), 1.0, 'All previously, so 100% is returned')
        self.assertEquals(first_cc.percentage_of_all_cards_delta(), 0.0, 'Same as last format, so no delta')
        self.assertEquals(first_cc.percentage_of_all_cards_perchange(), 0.0, 'No change... still 100%')

        self.assertEquals(first_cc.percentage_of_all_cards_previous(format_lookback_days=10), 1.0, 'F All previously, so 100% is returned')
        self.assertEquals(first_cc.percentage_of_all_cards_delta(format_lookback_days=10), 0.0, 'F Same as last format, so no delta')
        self.assertEquals(first_cc.percentage_of_all_cards_perchange(format_lookback_days=10), 0.0, 'F No change... still 100%')
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:55,代码来源:stattests.py

示例8: test_colors

    def test_colors(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        white = Color.objects.get(pk='W')
        blue = Color.objects.get(pk='U')
        black = Color.objects.get(pk='B')
        red = Color.objects.get(pk='R')
        green = Color.objects.get(pk='G')
        colorless = Color.objects.get(pk='c')
        colors = Color.objects.all()
        self.assertEqual(len(colors), 6)
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:12,代码来源:helpertests.py

示例9: test_basecards

    def test_basecards(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        names = ['Forest', 'Island', 'Mountain', 'Plains', 'Swamp']
        bcs = BaseCard.objects.all().order_by('filing_name')
        self.assertEquals(bcs.count(), 5)
        counter = 0
        for bc in bcs:
            self.assertEquals(bc.name, names[counter])
            self.assertEquals(bc.cmc, 0)
            counter = counter + 1
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:12,代码来源:helpertests.py

示例10: test_supertypes

    def test_supertypes(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        supertypes = (
            'Basic',
            'Legendary',
            'Snow',
            'World')
        dbtypes = Supertype.objects.all().order_by('supertype')
        self.assertEqual(dbtypes.count(), len(supertypes))
        for ttt in dbtypes:
            self.assertTrue(ttt.supertype in supertypes)
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:13,代码来源:helpertests.py

示例11: test_two_decks

    def test_two_decks(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        plains = BaseCard.objects.filter(name='Plains').first().physicalcard
        island = BaseCard.objects.filter(name='Island').first().physicalcard
        myform = Format.objects.filter(formatname='Modern').order_by('-start_date').first()

        tourny = Tournament(name='Test', url='http://foo.dog/', format=myform, start_date=myform.start_date, end_date=myform.start_date)
        tourny.save()
        #tourny = Tournament.objects.all().first()

        incr = 1
        for pcard in [plains, island]:
            tdeck = Deck()
            tdeck.name = 'My Deck Name'
            tdeck.url = 'http://card.ninja/'
            tdeck.visibility = tdeck.VISIBLE
            tdeck.authorname = 'Test Dude'
            tdeck.format = myform

            tdeck.save()
            tdeck = Deck.objects.get(pk=tdeck.id)

            dc1 = DeckCard()
            dc1.physicalcard = pcard
            dc1.deck = tdeck
            dc1.cardcount = 60
            dc1.board = DeckCard.MAIN
            dc1.save()

            td = TournamentDeck(tournament=tourny, deck=tdeck, place=incr)
            td.save()
            #td = TournamentDeck.objects.filter(tournament=tourny, deck=tdeck, place=incr).first()
            incr += 1

        FormatStat.calc_all()
        FormatCardStat.calc_all()

        fstat = FormatStat.objects.filter(format=myform).first()
        mstat = FormatCardStat.objects.filter(format=myform, physicalcard=island).first()

        dcount = mstat.deck_count
        self.assertEquals(dcount, 1)
        tdcount = fstat.tournamentdeck_count
        self.assertEquals(tdcount, 2)

        self.assertEquals(mstat.in_decks_percentage(), 50.0)
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:48,代码来源:stattests.py

示例12: test_empty

    def test_empty(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        island = BaseCard.objects.filter(name='Island').first().physicalcard
        modern = Format.objects.all().first()

        FormatStat.calc_all()
        FormatCardStat.calc_all()

        fstat = FormatStat.objects.filter(format=modern).first()
        mstat = FormatCardStat.objects.filter(format=modern, physicalcard=island).first()
        dcount = mstat.deck_count
        self.assertEquals(dcount, 0)
        tdcount = fstat.tournamentdeck_count
        self.assertEquals(tdcount, 0)
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:16,代码来源:stattests.py

示例13: test_rarities

    def test_rarities(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        b = Rarity.objects.get(pk='b')
        self.assertEqual(b.sortorder, 0)
        c = Rarity.objects.get(pk='c')
        self.assertEqual(c.sortorder, 1)
        u = Rarity.objects.get(pk='u')
        self.assertEqual(u.sortorder, 2)
        r = Rarity.objects.get(pk='r')
        self.assertEqual(r.sortorder, 3)
        m = Rarity.objects.get(pk='m')
        self.assertEqual(m.sortorder, 4)
        s = Rarity.objects.get(pk='s')
        self.assertEqual(s.sortorder, 5)
        rarities = Rarity.objects.all()
        self.assertEqual(len(rarities), 6)
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:18,代码来源:helpertests.py

示例14: test_deck_inst

    def test_deck_inst(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        tformat = Format.objects.all().first()

        tdeck = Deck()
        tdeck.name = 'My Deck Name'
        tdeck.url = 'http://card.ninja/'
        tdeck.visibility = tdeck.VISIBLE
        tdeck.authorname = 'Test Dude'
        tdeck.format = tformat

        tdeck.save()

        self.assertEquals(tdeck.format.id, tformat.id)

        c1 = Card.objects.filter(multiverseid=1002).first()
        self.assertEquals(c1.basecard.name, 'Island')

        dc1 = DeckCard()
        dc1.physicalcard = c1.basecard.physicalcard
        dc1.deck = tdeck
        dc1.cardcount = 8
        dc1.board = dc1.MAIN
        dc1.save()

        self.assertEquals(tdeck.get_card_count(), 8)

        c2 = Card.objects.filter(multiverseid=1004).first()
        self.assertEquals(c2.basecard.name, 'Mountain')

        dc2 = DeckCard()
        dc2.physicalcard = c2.basecard.physicalcard
        dc2.deck = tdeck
        dc2.cardcount = 3
        dc2.board = dc2.MAIN
        dc2.save()

        self.assertEquals(tdeck.get_card_count(), 11)
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:40,代码来源:tests.py

示例15: test_one_deck_abs_card

    def test_one_deck_abs_card(self):
        tlh = TestLoadHelper()
        tlh.basics_loader()

        mountain = BaseCard.objects.filter(name='Mountain').first().physicalcard
        island = BaseCard.objects.filter(name='Island').first().physicalcard
        myform = Format.objects.filter(formatname='Modern').order_by('-start_date').first()

        tdeck = Deck()
        tdeck.name = 'My Deck Name'
        tdeck.url = 'http://card.ninja/'
        tdeck.visibility = tdeck.VISIBLE
        tdeck.authorname = 'Test Dude'
        tdeck.format = myform

        tdeck.save()
        tdeck = Deck.objects.get(pk=tdeck.id)

        dc1 = DeckCard()
        dc1.physicalcard = island
        dc1.deck = tdeck
        dc1.cardcount = 60
        dc1.board = DeckCard.MAIN
        dc1.save()

        self.assertEquals(tdeck.get_card_count(), 60)

        tourny = Tournament(name='Test', url='http://foo.dog/', format=myform, start_date=myform.start_date, end_date=myform.start_date)
        tourny.save()
        #tourny = Tournament.objects.all().first()

        td = TournamentDeck(tournament=tourny, deck=tdeck, place=1)
        td.save()
        #td = TournamentDeck.objects.filter(tournament=tourny, deck=tdeck, place=1).first()

        FormatStat.calc_all()
        FormatCardStat.calc_all()

        fstat = FormatStat.objects.filter(format=myform).first()
        mstat = FormatCardStat.objects.filter(format=myform, physicalcard=mountain).first()

        dcount = mstat.deck_count
        self.assertEquals(dcount, 0)
        tdcount = fstat.tournamentdeck_count
        self.assertEquals(tdcount, 1, '1 Tournament Deck in the Format')

        self.assertEquals(mstat.in_decks_percentage(), 0.0, 'Mountain is in 0% of decks')

        self.assertEquals(mstat.occurence_count, 0, 'Mountain shows up 0 times in tournament decks')

        # the number of decks in this format that have this card
        self.assertEquals(mstat.deck_count, 0, '0 Tournament Decks have Mountain in the them')

        # the average card count when this card is included in a deck
        self.assertEquals(mstat.average_card_count_in_deck, 0.0, 'Average count of Mountain in Tournament Decks is 0')

        # the percentage of all cards in the format that are this card
        self.assertEquals(mstat.percentage_of_all_cards, 0.0, 'Average count of Tournament Decks with Mountain in it is 0')

        istat = FormatCardStat.objects.filter(format=myform, physicalcard=island).first()

        dcount = istat.deck_count
        self.assertEquals(dcount, 1, '1 Tournament Deck that has Island in it')
        self.assertEquals(istat.in_decks_percentage(), 100.0, 'Island is in 100% of decks')

        self.assertEquals(istat.occurence_count, 60, 'Island shows up 0 times in tournament decks')

        # the number of decks in this format that have this card
        self.assertEquals(istat.deck_count, 1, '1 Tournament Decks have Island in the them')

        # the average card count when this card is included in a deck
        self.assertEquals(istat.average_card_count_in_deck, 60.0, 'Average count of Island in Tournament Decks is 60')

        # the percentage of all cards in the format that are this card
        self.assertEquals(
            istat.percentage_of_all_cards,
            1.0,
            'Average count of Tournament Decks with Island in it should be 100, not {}'.format(
                istat.percentage_of_all_cards))
开发者ID:jcrickmer,项目名称:mtgdbpy,代码行数:79,代码来源:stattests.py


注:本文中的cards.tests.helper.TestLoadHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。