Example #1
0
class TestIntegrity:

    @staticmethod
    def fetch_fk_data(data, fk_id):
        return next(iter([d for d in data if d["id"] == fk_id]), None)

    @pytest.mark.parametrize("content_type", list(set(CONTENT_TYPES.as_list).difference(CONTENT_TYPES.without_ids)))
    def test_no_skipped_or_duplicate_id_numbers(self, content_type):
        data = get_data(content_type)
        assert set(range(len(data))) == set([d["id"] for d in data])

    @pytest.mark.parametrize("source_contents_entry", get_data(CONTENT_TYPES.SOURCE_CONTENTS))
    def test_source_contents_foreign_keys(self, source_contents_entry, all_data):
        fk_content_type_data = all_data.get(source_contents_entry["content_type"])

        assert fk_content_type_data is not None
        assert source_contents_entry["content_type"] != CONTENT_TYPES.SOURCE
        assert self.fetch_fk_data(fk_content_type_data, source_contents_entry["content_id"]) is not None
        assert self.fetch_fk_data(all_data[CONTENT_TYPES.SOURCE], source_contents_entry["source_id"]) is not None

    @pytest.mark.parametrize("agenda_card_entry", get_data(CONTENT_TYPES.AGENDA))
    def test_agenda_deck_foreign_keys(self, agenda_card_entry, agenda_decks):
        assert self.fetch_fk_data(agenda_decks, agenda_card_entry["agenda_id"]) is not None

    @pytest.mark.parametrize("hero_class_card_entry", get_data(CONTENT_TYPES.HERO_CLASS))
    def test_hero_class_cards_foreign_keys(self, hero_class_card_entry, heroes):
        assert self.fetch_fk_data(heroes, hero_class_card_entry["hero_id"]) is not None

    @pytest.mark.parametrize("imperial_class_card_entry", get_data(CONTENT_TYPES.IMPERIAL_CLASS_CARD))
    def test_imperial_class_cards_foreign_keys(self, imperial_class_card_entry, imperial_classes):
        assert self.fetch_fk_data(imperial_classes, imperial_class_card_entry["class_id"]) is not None
Example #2
0
class TestRewardIntegrity:

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.REWARD) if d['type'] == BUFF_TYPES.FEAT
    ])
    def test_unique_deployment_does_not_have_a_reinforce_cost(self, entry):
        assert entry['traits'] is None
Example #3
0
import unittest
from unittest import mock

import pandas

from tests.utils import get_data
from google_objects.sheets import SheetsClient
from google_objects.sheets import Spreadsheet
from google_objects.sheets import Sheet
from google_objects.sheets import Block

# load google sheets dummy data
spreadsheet = get_data('spreadsheet')
values = get_data('range')

# initialize mock google-api-python-client resource object
mock_resource = mock.Mock()
mock_resource.spreadsheets().get().execute.return_value = spreadsheet
mock_resource.spreadsheets().values().get().execute.return_value = values


class TestSheets(unittest.TestCase):
    """Test Google Sheets objects"""
    def setUp(self):
        self.client = SheetsClient(mock_resource)

    def test_spreadsheets(self):
        spreadsheet = self.client.get_spreadsheet('abc123')
        self.assertIsInstance(spreadsheet, Spreadsheet)

        # test spreadsheet properties
import unittest
from unittest import mock

from tests.utils import get_data
from google_objects.slides import SlidesClient
from google_objects.slides import Presentation
from google_objects.slides import Page
from google_objects.slides import PageElement

# load google sheets dummy data
presentation = get_data('presentation')

# initialize mock google-api-python-client resource object
mock_resource = mock.Mock()
mock_resource.presentations().get().execute.return_value = presentation


class TestDrive(unittest.TestCase):
    def setUp(self):
        self.client = SlidesClient(mock_resource)

    def test_presentation(self):
        presentation = self.client.get_presentation('abc123')
        self.assertIsInstance(presentation, Presentation)
        self.assertEqual(presentation.id, 'abc123')

    def test_pages(self):
        presentation = self.client.get_presentation('abc123')

        for slide in presentation.slides():
            self.assertIsInstance(slide, Page)
Example #5
0
def test_data():
    return get_data()
Example #6
0
import unittest
from unittest import mock

from tests.utils import get_data
from google_objects.drive import DriveClient
from google_objects.drive import About
from google_objects.drive import File
from google_objects.drive import Permission

# load google sheets dummy data
about = get_data('about')
get_file = get_data('get_file')
copy_file = get_data('copy_file')
permission = get_data('permission')

# initialize mock google-api-python-client resource object
mock_resource = mock.Mock()
mock_resource.about().get().execute.return_value = about
mock_resource.files().get().execute.return_value = get_file
mock_resource.files().copy().execute.return_value = copy_file
mock_resource.permissions().create().execute.return_value = permission


class TestDrive(unittest.TestCase):
    """Test Google Sheets objects"""
    def setUp(self):
        self.client = DriveClient(mock_resource)

    def test_about(self):
        about = self.client.get_about('abc123')
        self.assertIsInstance(about, About)
Example #7
0
class TestDeploymentsIntegrity:
    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT) if DEPLOYMENT_TRAITS.SKIRMISH_UPGRADE in d['traits']
    ])
    def test_skirmish_upgrades_have_skirmish_game_mode_only(self, entry):
        assert entry['modes'] == [GAME_MODES.SKIRMISH, ]

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT) if DEPLOYMENT_TRAITS.SKIRMISH_UPGRADE in d['traits']
    ])
    def test_skirmish_upgrades_do_not_have_health(self, entry):
        assert entry['health'] is None

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT) if DEPLOYMENT_TRAITS.SKIRMISH_UPGRADE in d['traits']
    ])
    def test_skirmish_upgrades_do_not_have_speed(self, entry):
        assert entry['speed'] is None

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT) if DEPLOYMENT_TRAITS.SKIRMISH_UPGRADE in d['traits']
    ])
    def test_skirmish_upgrades_do_not_have_deployment_group(self, entry):
        assert entry['deployment_group'] is None

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT) if DEPLOYMENT_TRAITS.SKIRMISH_UPGRADE in d['traits']
    ])
    def test_skirmish_upgrades_do_not_have_reinforce_cost(self, entry):
        assert entry['reinforce_cost'] is None

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT) if d['deployment_group'] is not None
    ])
    def test_reinforce_cost_only_available_if_appropriate(self, entry):
        if entry['deployment_group'] > 1:
            assert entry['reinforce_cost'] is not None
            assert entry['reinforce_cost'] > 0
        else:
            assert entry['reinforce_cost'] is None

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT)
        if DEPLOYMENT_TRAITS.SKIRMISH_UPGRADE not in d['traits'] and d['unique']
    ])
    def test_unique_deployment_does_not_have_a_reinforce_cost(self, entry):
        assert entry['reinforce_cost'] is None

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT)
        if DEPLOYMENT_TRAITS.SKIRMISH_UPGRADE not in d['traits'] and d['unique']
    ])
    def test_unique_deployment_have_a_deployment_group_of_1(self, entry):
        assert entry['deployment_group'] == 1

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT) if d['deployment_group'] is not None and d['deployment_group'] > 1
    ])
    def test_deployment_has_reinforce_cost_if_deployment_group(self, entry):
        assert entry['reinforce_cost'] > 0

    @pytest.mark.parametrize("entry", [
        d for d in get_data(CONTENT_TYPES.DEPLOYMENT) if d['reinforce_cost'] is not None and d['reinforce_cost'] > 1
    ])
    def test_deployment_has_deployment_group_if_reinforce_cost(self, entry):
        assert entry['deployment_group'] > 1
Example #8
0
 def test_no_skipped_or_duplicate_id_numbers(self, content_type):
     data = get_data(content_type)
     assert set(range(len(data))) == set([d["id"] for d in data])
Example #9
0
def source_contents():
    return sorted(get_data(CONTENT_TYPES.SOURCE_CONTENTS),
                  key=lambda m: (m['source_id'], m['content_type']))
Example #10
0
def form_cards():
    return get_data(CONTENT_TYPES.FORM_CARDS)
Example #11
0
def threat_mission_cards():
    return get_data(CONTENT_TYPES.THREAT_MISSION)
Example #12
0
def imperial_classes():
    return get_data(CONTENT_TYPES.IMPERIAL_CLASSES)
Example #13
0
def heroes():
    return get_data(CONTENT_TYPES.HERO)
Example #14
0
def agenda_decks():
    return get_data(CONTENT_TYPES.AGENDA_DECKS)