Example #1
0
    def test_card_heuristics(self):
        # this inserts if and only if it's needed
        get_cards_from_names('Lingering Souls')
        c = Client()
        response = c.get('/heuristics/', {}, "text/json",
                         HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        content = [h['key'] for h in self.get_json_from_response(response)]

        self.assertIn('token_spells_are_creatures', content)
        self.assertIn('off_color_flashback_is_gold', content)
Example #2
0
 def test_contents_handling_duplicates_on_fetch_with_mismatches(self):
     get_cards_from_names('AEther Adept')
     self.assert_card_contents(
         ['AEther Adept', 'Aether Adept', 'aether adept'],
         # as of now there's on one being fetched, since we haven't
         # answer any external questions about mismatches
         fetched=[u'\xc6ther Adept'])
     get_cards_from_names('Aether Adept', 'aether adept')
     self.assert_card_contents(
         ['AEther Adept', 'Aether Adept', 'aether adept'],
         # as of now there's on one being fetched, since we haven't
         # answer any external questions about mismatches
         fetched=[
             u'\xc6ther Adept',
             u'\xc6ther Adept',
             u'\xc6ther Adept'
         ])
Example #3
0
def save_cube_from_file_path(fpath):
    file_name = os.path.basename(fpath)

    try:
        if not os.path.exists(fpath):
            raise CommandError("{} does not exist".format(fpath))
        cube = Cube.objects.get(name=file_name)
    except Cube.DoesNotExist:
        cube = Cube(name=file_name)
        cube.save()

    with open(fpath, "r") as cube_file:
        cards = get_cards_from_names(*[line for line in cube_file.read().splitlines() if line])

    cube.cards = cards
    cube.save()

    return cube
Example #4
0
    def test_handle_bad_name(self):

        self.assertEqual([], get_cards_from_names('Lanowar Elf',
                                                  'Llanowar Elfs',
                                                  'Llan O\' War Elves'))
Example #5
0
    def test_contents_handling_duplicates_on_fetch(self):
        get_cards_from_names('Gravecrawler')

        self.assert_card_contents(['Gravecrawler'] * 3, fetched=[
            'Gravecrawler', 'Gravecrawler', 'Gravecrawler'
        ])